]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't canonicalize target
authorKarel Zak <kzak@redhat.com>
Thu, 17 May 2012 10:10:43 +0000 (12:10 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 17 May 2012 10:10:43 +0000 (12:10 +0200)
Note that mountpoint (target_ paths in /proc/mounts and /proc/self/mountinfo
are always canonicalized by kernel.

 * for umount we don't have to canonicalize target
   by default if the mountpoint is found in /proc/self/mountinfo

 * in mnt_table_find_target() is unnecessary to canonicalize target paths
   if the table of the filesystems is read from /proc/self/mountinfo

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=820707
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_umount.c
libmount/src/fs.c
libmount/src/tab.c

index 3443da11bc3164827da18d939f3bc5e3ace1d5a4..39d940f6c2fbc8dce9a69a3c4067ab764693f2ce 100644 (file)
@@ -604,8 +604,6 @@ int mnt_context_prepare_umount(struct libmnt_context *cxt)
                rc = mnt_context_merge_mflags(cxt);
        if (!rc)
                rc = evaluate_permissions(cxt);
-       if (!rc)
-              rc = mnt_context_prepare_target(cxt);
 
        if (!rc && !cxt->helper) {
 
index 22addb9f42f4fda1857d7e62d7545de34dc589cf..543ffb153728e8473eed4f872b8df94df38aeaab 100644 (file)
@@ -1208,7 +1208,8 @@ int mnt_fs_get_attribute(struct libmnt_fs *fs, const char *name,
  * Possible are three attempts:
  *     1) compare @target with @fs->target
  *     2) realpath(@target) with @fs->target
- *     3) realpath(@target) with realpath(@fs->target).
+ *     3) realpath(@target) with realpath(@fs->target) if @fs is not from
+ *        /proc/self/mountinfo.
  *
  * The 2nd and 3rd attempts are not performed when @cache is NULL.
  *
@@ -1231,7 +1232,7 @@ int mnt_fs_match_target(struct libmnt_fs *fs, const char *target,
                rc = (cn && strcmp(cn, fs->target) == 0);
 
                /* 3) - canonicalized and canonicalized */
-               if (!rc && cn) {
+               if (!rc && cn && !mnt_fs_is_kernel(fs)) {
                        char *tcn = mnt_resolve_path(fs->target, cache);
                        rc = (tcn && strcmp(cn, tcn) == 0);
                }
index 9c41c99a2c0c94f3a92ea4e18bd11f6ca12ddc57..927e0f8dadb9e351c61ae4f7e30f54c287428131 100644 (file)
@@ -456,13 +456,18 @@ struct libmnt_fs *mnt_table_find_target(struct libmnt_table *tb, const char *pat
                        return fs;
        }
 
-       /* non-canonicaled path in struct libmnt_table */
+       /* non-canonicaled path in struct libmnt_table
+        * -- note that mountpoint in /proc/self/mountinfo is already
+        *    canonicalized by kernel
+        */
        mnt_reset_iter(&itr, direction);
        while(mnt_table_next_fs(tb, &itr, &fs) == 0) {
                char *p;
 
-               if (!fs->target || mnt_fs_is_swaparea(fs) ||
-                   (*fs->target == '/' && *(fs->target + 1) == '\0'))
+               if (!fs->target
+                   || mnt_fs_is_swaparea(fs)
+                   || mnt_fs_is_kernel(fs)
+                   || (*fs->target == '/' && *(fs->target + 1) == '\0'))
                       continue;
 
                p = mnt_resolve_path(fs->target, tb->cache);