summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2014-12-17 21:05:58 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-12-20 10:26:02 -0500
commitb5a7205f6edc5525dd2ee0a91bb051dabcd331d9 (patch)
treec0ec7f67e29e36e1b8f6c7baa50a0ed7fe8e17b7 /src/shared
parenta2092eadcc8bd8c9eabf0b7aac892521845c8c63 (diff)
path: make the check for unsupported name_to_handle_at symmetric
If child supports, but the parent does not, or when the child does not support, but the parent does, assume the child is a mount point. Only if neither supports use the fallback. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/path-util.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index be320f50ca..c0ffacdfeb 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -323,6 +323,7 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
_cleanup_free_ char *parent = NULL;
struct stat a, b;
int r;
+ bool nosupp = false;
/* We are not actually interested in the file handles, but
* name_to_handle_at() also passes us the mount ID, hence use
@@ -337,12 +338,11 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
/* This kernel or file system does not support
* name_to_handle_at(), hence fallback to the
* traditional stat() logic */
- goto fallback;
-
- if (errno == ENOENT)
+ nosupp = true;
+ else if (errno == ENOENT)
return 0;
-
- return -errno;
+ else
+ return -errno;
}
r = path_get_parent(t, &parent);
@@ -351,17 +351,22 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
h.handle.handle_bytes = MAX_HANDLE_SZ;
r = name_to_handle_at(AT_FDCWD, parent, &h.handle, &mount_id_parent, AT_SYMLINK_FOLLOW);
- if (r < 0) {
- /* The parent can't do name_to_handle_at() but the
- * directory we are interested in can? If so, it must
- * be a mount point */
+ if (r < 0)
if (errno == EOPNOTSUPP)
- return 1;
-
- return -errno;
- }
-
- return mount_id != mount_id_parent;
+ if (nosupp)
+ /* Neither parent nor child do name_to_handle_at()?
+ We have no choice but to fall back. */
+ goto fallback;
+ else
+ /* The parent can't do name_to_handle_at() but
+ * the directory we are interested in can?
+ * Or the other way around?
+ * If so, it must be a mount point. */
+ return 1;
+ else
+ return -errno;
+ else
+ return mount_id != mount_id_parent;
fallback:
if (allow_symlink)