chiark / gitweb /
fs-util: add new CHASE_TRAIL_SLASH flag for chase_symlinks()
authorLennart Poettering <lennart@poettering.net>
Thu, 22 Mar 2018 18:54:24 +0000 (19:54 +0100)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
commit33da2d049720dfa17bbbbf70200130fd977bfb33
tree1acb80e63d443e3e0d048af47a036a2b4d83a489
parentac1936363db2bf6284d225ab6f221e5e9b25470b
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
src/basic/fs-util.c
src/basic/fs-util.h
src/basic/mount-util.c