[systemd-commits] src/shared

Dave Reisner dreisner at kemper.freedesktop.org
Thu Dec 18 15:35:30 PST 2014


 src/shared/path-util.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit e40872fc538f3216fd4d00aa969785b999a357bf
Author: Dave Reisner <dreisner at archlinux.org>
Date:   Thu Dec 18 18:10:46 2014 -0500

    path-util: fix breakage in path_is_mount_point
    
    This fixes 2 problems introduced by 6feeeab0bc:
    
    1) If name_to_handle_at returns ENOSYS for the child, we'll wrongly
    return -ENOSYS when it returns the same for the parent. Immediately
    jump to the fallback logic when we get ENOSYS.
    
    2) If name_to_handle_at returns EOPNOTSUPP for the child but suceeds
    for the parent, we'll be comparing an uninitialized value (mount_id) to
    an initialized value (mount_id_parent). Initialize the mount_id
    variables to invalid mount_ids to avoid this.

diff --git a/src/shared/path-util.c b/src/shared/path-util.c
index 8c43d06..ad9dc88 100644
--- a/src/shared/path-util.c
+++ b/src/shared/path-util.c
@@ -458,7 +458,7 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
                 .handle.handle_bytes = MAX_HANDLE_SZ
         };
 
-        int mount_id, mount_id_parent;
+        int mount_id = -1, mount_id_parent = -1;
         _cleanup_free_ char *parent = NULL;
         struct stat a, b;
         int r;
@@ -473,7 +473,11 @@ int path_is_mount_point(const char *t, bool allow_symlink) {
 
         r = name_to_handle_at(AT_FDCWD, t, &h.handle, &mount_id, allow_symlink ? AT_SYMLINK_FOLLOW : 0);
         if (r < 0) {
-                if (IN_SET(errno, ENOSYS, EOPNOTSUPP))
+                if (errno == ENOSYS)
+                        /* This kernel does not support name_to_handle_at()
+                         * fall back to the traditional stat() logic. */
+                        goto fallback;
+                else if (errno == EOPNOTSUPP)
                         /* This kernel or file system does not support
                          * name_to_handle_at(), hence fallback to the
                          * traditional stat() logic */



More information about the systemd-commits mailing list