summaryrefslogtreecommitdiff
path: root/src/shared/path-util.h
diff options
context:
space:
mode:
authorMartin Pitt <martin.pitt@ubuntu.com>2015-05-27 09:56:03 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2015-05-29 17:40:12 +0200
commit5d409034017e9f9f8c4392157d95511fc2e05d87 (patch)
treee0223a0ec6b7ec9c516e00370da305e5f8c2d96a /src/shared/path-util.h
parent2fe9e87a2475d5c2f5e2bb1a7e711c59fd0b2c6d (diff)
path-util: Fix path_is_mount_point for files
Commits 27cc6f166 and f25afeb broke path_is_mount_point() for files (such as /etc/machine-id → /run/machine-id bind mounts) as with the factorization of fd_is_mount_point() we lost the parent directory. We cannot determine that from an fd only as openat(fd, "..") only works for directory fds. Change fd_is_mount_point() to behave like openat(): It now takes a file descriptor of the containing directory, a file name in it, and flags (which can be 0 or AT_SYMLINK_FOLLOW). Unlike name_to_handle_at() or openat(), fstatat() only accepts the inverse flag AT_SYMLINK_NOFOLLOW and complains with EINVAL about AT_SYMLINK_FOLLOW; so we need to transform the flags for that fallback. Adjust rm_rf_children() accordingly (only other caller of fd_is_mount_point() aside from path_is_mount_point()). Add test cases for files, links, and file bind mounts (the latter will only work when running as root). Split out a new test_path_is_mount_point() test case function as it got significantly larger now.
Diffstat (limited to 'src/shared/path-util.h')
-rw-r--r--src/shared/path-util.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/shared/path-util.h b/src/shared/path-util.h
index 4f45cfd2b7..38ad799ba0 100644
--- a/src/shared/path-util.h
+++ b/src/shared/path-util.h
@@ -53,7 +53,7 @@ char** path_strv_make_absolute_cwd(char **l);
char** path_strv_resolve(char **l, const char *prefix);
char** path_strv_resolve_uniq(char **l, const char *prefix);
-int fd_is_mount_point(int fd);
+int fd_is_mount_point(int fd, const char *filename, int flags);
int path_is_mount_point(const char *path, bool allow_symlink);
int path_is_read_only_fs(const char *path);
int path_is_os_tree(const char *path);