diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-03-22 19:54:24 +0100 |
---|---|---|
committer | Sven Eden <yamakuzure@gmx.net> | 2018-08-24 16:47:08 +0200 |
commit | 33da2d049720dfa17bbbbf70200130fd977bfb33 (patch) | |
tree | 1acb80e63d443e3e0d048af47a036a2b4d83a489 /src/basic/mount-util.c | |
parent | ac1936363db2bf6284d225ab6f221e5e9b25470b (diff) |
fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()
This rearranges chase_symlinks() a bit: if no special flags are
specified it will now revert to behaviour before
b12d25a8d631af00b200e7aa9dbba6ba4a4a59ff. However, if the new
CHASE_TRAIL_SLASH flag is specified it will follow the behaviour
introduced by that commit.
I wasn't sure which one to make the beaviour that requires specification
of a flag to enable. I opted to make the "append trailing slash"
behaviour the one to enable by a flag, following the thinking that the
function should primarily be used to generate a normalized path, and I
am pretty sure a path without trailing slash is the more "normalized"
one, as the trailing slash is not really a part of it, but merely a
"decorator" that tells various system calls to generate ENOTDIR if the
path doesn't refer to a path.
Or to say this differently: if the slash was part of normalization then
we really should add it in all cases when the final path is a directory,
not just when the user originally specified it.
Fixes: #8544
Replaces: #8545
Diffstat (limited to 'src/basic/mount-util.c')
-rw-r--r-- | src/basic/mount-util.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/basic/mount-util.c b/src/basic/mount-util.c index b74d51a26..751702d33 100644 --- a/src/basic/mount-util.c +++ b/src/basic/mount-util.c @@ -81,8 +81,10 @@ int name_to_handle_at_loop( if (name_to_handle_at(fd, path, h, &mnt_id, flags) >= 0) { - if (ret_handle) - *ret_handle = TAKE_PTR(h); + if (ret_handle) { + *ret_handle = h; + h = NULL; + } if (ret_mnt_id) *ret_mnt_id = mnt_id; @@ -294,7 +296,7 @@ int path_is_mount_point(const char *t, const char *root, int flags) { * /bin -> /usr/bin/ and /usr is a mount point, then the parent that we * look at needs to be /usr, not /. */ if (flags & AT_SYMLINK_FOLLOW) { - r = chase_symlinks(t, root, 0, &canonical); + r = chase_symlinks(t, root, CHASE_TRAIL_SLASH, &canonical); if (r < 0) return r; @@ -954,7 +956,8 @@ int mount_option_mangle( } *ret_mount_flags = mount_flags; - *ret_remaining_options = TAKE_PTR(ret); + *ret_remaining_options = ret; + ret = NULL; return 0; } |