]> git.ipfire.org Git - thirdparty/systemd.git/commit
util-lib: use trailing slash in chase_symlinks, fd_is_mount_point, path_is_mount_point
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 31 Oct 2017 10:08:30 +0000 (11:08 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 30 Nov 2017 19:43:25 +0000 (20:43 +0100)
commitb12d25a8d631af00b200e7aa9dbba6ba4a4a59ff
tree77bbba004085576e5e646ba4a64c6981b4043cbf
parentca4d708dc4092268520aee419cbd696f1b0f4558
util-lib: use trailing slash in chase_symlinks, fd_is_mount_point, path_is_mount_point

The kernel will reply with -ENOTDIR when we try to access a non-directory under
a name which ends with a slash. But our functions would strip the trailing slash
under various circumstances. Keep the trailing slash, so that

path_is_mount_point("/path/to/file/") return -ENOTDIR when /path/to/file/ is a file.

Tests are added for this change in behaviour.

Also, when called with a trailing slash, path_is_mount_point() would get
"" from basename(), and call name_to_handle_at(3, "", ...), and always
return -ENOENT. Now it'll return -ENOTDIR if the mount point is a file, and
true if it is a directory and a mount point.

v2:
- use strip_trailing_chars()

v3:
- instead of stripping trailing chars(), do the opposite — preserve them.
src/basic/fs-util.c
src/basic/mount-util.c
src/basic/path-util.c
src/basic/path-util.h
src/test/test-fs-util.c
src/test/test-mount-util.c
src/test/test-path-util.c