diff options
author | Tom Gundersen <teg@jklm.no> | 2015-02-11 16:21:18 -0500 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-02-11 16:21:58 -0500 |
commit | b39a4a3aba7e8593684b6e44b0780c2439e84d7d (patch) | |
tree | e4cdb633a310bae4689a4f44b306e778b974b628 /src/shared | |
parent | 691df3c5c399899a9fd6624f6148883cc20fa18a (diff) |
udev: event - move renaming of udev_device to libudev
This is not exposed in the public API. We want to simplify the internal libudev-device API as much as possible
so that it will be simpler to rip the whole thing out in the future.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/util.c | 18 | ||||
-rw-r--r-- | src/shared/util.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index e76325e7c2..091b3c04a1 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -846,6 +846,24 @@ ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll) { return n; } +char* dirname_malloc(const char *path) { + char *d, *dir, *dir2; + + d = strdup(path); + if (!d) + return NULL; + dir = dirname(d); + assert(dir); + + if (dir != d) { + dir2 = strdup(dir); + free(d); + return dir2; + } + + return dir; +} + int dev_urandom(void *p, size_t n) { static int have_syscall = -1; int r, fd; diff --git a/src/shared/util.h b/src/shared/util.h index c5dd6bde0a..9458a1942f 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -275,6 +275,9 @@ int flush_fd(int fd); int fopen_temporary(const char *path, FILE **_f, char **_temp_path); ssize_t loop_read(int fd, void *buf, size_t nbytes, bool do_poll); + +char* dirname_malloc(const char *path); + int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid); bool null_or_empty(struct stat *st) _pure_; |