diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-10-04 17:34:03 +0200 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2017-10-04 17:34:03 +0200 |
commit | be1d8c84ebe7d240e06df26176ac98d91b37fd79 (patch) | |
tree | ff3d864be15cc2f92f42f219c0772d4572f0d03c /src/basic/fs-util.c | |
parent | b1de39eefe5eae5c9ade8af6bf50acb66c0ba950 (diff) |
fs-util: small tweak in chase_symlinks()
If we follow an absolute symlink there's no need to prefix the path with
a "/", since by definition it already has one.
This helps suppressing double "/" in resolved paths containing absolute
symlinks.
Diffstat (limited to 'src/basic/fs-util.c')
-rw-r--r-- | src/basic/fs-util.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/basic/fs-util.c b/src/basic/fs-util.c index 28b2dce33..d63eeb1d2 100644 --- a/src/basic/fs-util.c +++ b/src/basic/fs-util.c @@ -781,12 +781,11 @@ int chase_symlinks(const char *path, const char *original_root, unsigned flags, return -ENOMEM; } - } - - /* 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); + /* 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); + } else + joined = strjoin("/", destination, todo); if (!joined) return -ENOMEM; |