[systemd-commits] 2 commits - src/shared
Zbigniew Jędrzejewski-Szmek
zbyszek at kemper.freedesktop.org
Wed Dec 17 18:08:52 PST 2014
src/shared/path-util.c | 37 +++++++++++++++++++++----------------
1 file changed, 21 insertions(+), 16 deletions(-)
New commits:
commit 6feeeab0bc40b5a7f208adf79909fb85e2208e8e
Author: Zbigniew Jędrzejewski-Szmek <zbyszek at in.waw.pl>
Date: Wed Dec 17 21:05:58 2014 -0500
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.
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index fae5d20..8c43d06 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -462,6 +462,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
@@ -476,12 +477,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);
@@ -490,17 +490,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)
commit b890bf6a81acfc989743ef7a66ba5710aec66411
Author: Umut Tezduyar Lindskog <umut.tezduyar at axis.com>
Date: Wed Dec 17 19:43:58 2014 -0500
path: follow symbolic link for parent path (2)
c0e57ba9e22ee937722958d8b912ade2a37f206d fixed the fallback path.
We should do the same for name_to_handle_at().
diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 9e2fd64..fae5d20 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -489,7 +489,7 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
return r;
h.handle.handle_bytes = MAX_HANDLE_SZ;
- r = name_to_handle_at(AT_FDCWD, parent, &h.handle, &mount_id_parent, 0);
+ 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
More information about the systemd-commits
mailing list