X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fbasic%2Ffs-util.c;h=6308216deeaab1129dc04b54a9baa91f121540ce;hp=05f10c86f827a9c9f86aa73794f8f014dddf6138;hb=9b00a533195b7fec54a791ca02090e0799214770;hpb=701d4cf38514d96ea0618807ac3b08a9e52c60cd diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 05f10c86f..6308216de 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -37,6 +37,7 @@ #include "mkdir.h" #include "parse-util.h" #include "path-util.h" +#include "stat-util.h" #include "string-util.h" #include "strv.h" //#include "time-util.h" @@ -491,7 +492,6 @@ int get_files_in_directory(const char *path, char ***list) { return n; } -#if 0 /// UNNEEDED by elogind static int getenv_tmp_dir(const char **ret_path) { const char *n; int r, ret = 0; @@ -562,6 +562,7 @@ static int tmp_dir_internal(const char *def, const char **ret) { return 0; } +#if 0 /// UNNEEDED by elogind int var_tmp_dir(const char **ret) { /* Returns the location for "larger" temporary files, that is backed by physical storage if available, and thus @@ -571,6 +572,7 @@ int var_tmp_dir(const char **ret) { return tmp_dir_internal("/var/tmp", ret); } +#endif // 0 int tmp_dir(const char **ret) { @@ -580,6 +582,7 @@ int tmp_dir(const char **ret) { return tmp_dir_internal("/tmp", ret); } +#if 0 /// UNNEEDED by elogind int inotify_add_watch_fd(int fd, int what, uint32_t mask) { char path[strlen("/proc/self/fd/") + DECIMAL_STR_MAX(int) + 1]; int r; @@ -593,6 +596,7 @@ int inotify_add_watch_fd(int fd, int what, uint32_t mask) { return r; } +#endif // 0 int chase_symlinks(const char *path, const char *original_root, unsigned flags, char **ret) { _cleanup_free_ char *buffer = NULL, *done = NULL, *root = NULL; @@ -728,6 +732,8 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, return -errno; if (S_ISLNK(st.st_mode)) { + char *joined; + _cleanup_free_ char *destination = NULL; /* This is a symlink, in this case read the destination. But let's make sure we don't follow @@ -751,9 +757,6 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, if (fd < 0) return -errno; - free_and_replace(buffer, destination); - - todo = buffer; free(done); /* Note that we do not revalidate the root, we take it as is. */ @@ -765,19 +768,17 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, return -ENOMEM; } - } else { - char *joined; + } - /* A relative destination. If so, this is what we'll prefix what's left to do with what - * we just read, and start the loop again, but remain in the current directory. */ + /* Prefix what's left to do with what we just read, and start the loop again, + * but remain in the current directory. */ - joined = strjoin("/", destination, todo); - if (!joined) - return -ENOMEM; + joined = strjoin("/", destination, todo); + if (!joined) + return -ENOMEM; - free(buffer); - todo = buffer = joined; - } + free(buffer); + todo = buffer = joined; continue; } @@ -809,4 +810,3 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, return exists; } -#endif // 0