]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
fs-util: drop readlink_and_canonicalize()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2018 07:49:54 +0000 (16:49 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Feb 2018 07:49:54 +0000 (16:49 +0900)
src/basic/fs-util.c
src/basic/fs-util.h
src/test/test-copy.c

index a8e50d4c785c86f3e68923aacb85f629bf5bd382..bedde4138965f40d09920c747a1dac5a121765aa 100644 (file)
@@ -225,29 +225,6 @@ int readlink_and_make_absolute(const char *p, char **r) {
         return 0;
 }
 
-int readlink_and_canonicalize(const char *p, const char *root, char **ret) {
-        char *t, *s;
-        int r;
-
-        assert(p);
-        assert(ret);
-
-        r = readlink_and_make_absolute(p, &t);
-        if (r < 0)
-                return r;
-
-        r = chase_symlinks(t, root, 0, &s);
-        if (r < 0)
-                /* If we can't follow up, then let's return the original string, slightly cleaned up. */
-                *ret = path_kill_slashes(t);
-        else {
-                *ret = s;
-                free(t);
-        }
-
-        return 0;
-}
-
 int readlink_and_make_absolute_root(const char *root, const char *path, char **ret) {
         _cleanup_free_ char *target = NULL, *t = NULL;
         const char *full;
index 4dba1ea56adb511731a7d603a6339cfceeb86cca..c4b81858fdcc60c45bd572da164b55cb86951c01 100644 (file)
@@ -41,7 +41,6 @@ int readlinkat_malloc(int fd, const char *p, char **ret);
 int readlink_malloc(const char *p, char **r);
 int readlink_value(const char *p, char **ret);
 int readlink_and_make_absolute(const char *p, char **r);
-int readlink_and_canonicalize(const char *p, const char *root, char **r);
 int readlink_and_make_absolute_root(const char *root, const char *path, char **ret);
 
 int chmod_and_chown(const char *path, mode_t mode, uid_t uid, gid_t gid);
index d277b78c5b3bf6f0321a73f9b5d28a6390701447..1dde878a9e885d1b8ddbba057d2633e484999e5d 100644 (file)
@@ -146,7 +146,7 @@ static void test_copy_tree(void) {
                 assert_se((f = strjoin(original_dir, *p)));
                 assert_se((l = strjoin(copy_dir, *link)));
 
-                assert_se(readlink_and_canonicalize(l, NULL, &target) == 0);
+                assert_se(chase_symlinks(l, NULL, 0, &target) == 1);
                 assert_se(path_equal(f, target));
         }