]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
umount: support non-canonical devnames in mtab
authorKarel Zak <kzak@redhat.com>
Mon, 11 Apr 2011 12:05:57 +0000 (14:05 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Apr 2011 12:05:57 +0000 (14:05 +0200)
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/755193
Signed-off-by: Karel Zak <kzak@redhat.com>
mount/fstab.c
mount/umount.c

index 32b8dac181cb8d1bb9f40189fdaed9ad1a78df6d..fd53ca4beb4e17ec1aee7555e94b280d3f180b4d 100644 (file)
@@ -307,10 +307,23 @@ getmntdevbackward (const char *name, struct mntentchn *mcprev) {
        mc0 = mtab_head();
        if (!mcprev)
                mcprev = mc0;
+
+       /* canonical names in mtab */
        for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) {
                if (streq(mc->m.mnt_fsname, name))
                        return mc;
        }
+
+       /* non-canonical names in mtab (this is BAD THING!) */
+       for (mc = mcprev->prev; mc && mc != mc0; mc = mc->prev) {
+               char *cn = canonicalize(mc->m.mnt_fsname);
+               int res = cn ? streq(cn, name) : 0;
+
+               free(cn);
+               if (res)
+                       return mc;
+       }
+
        return NULL;
 }
 
index 2e7bd31cef4bb6505b72a7f8588c8bf84b343c62..add6c87daae6f1e906a8003bb44b8546eac26e63 100644 (file)
@@ -634,6 +634,7 @@ umount_file (char *arg) {
                mc = getmntdevbackward(file, NULL);
                if (mc) {
                        struct mntentchn *mc1;
+                       char *cn;
 
                        mc1 = getmntdirbackward(mc->m.mnt_dir, NULL);
                        if (!mc1)
@@ -642,13 +643,15 @@ umount_file (char *arg) {
                                die(EX_SOFTWARE,
                                    _("umount: confused when analyzing mtab"));
 
-                       if (strcmp(file, mc1->m.mnt_fsname)) {
+                       cn = canonicalize(mc1->m.mnt_fsname);
+                       if (cn && strcmp(file, cn)) {
                                /* Something was stacked over `file' on the
                                   same mount point. */
                                die(EX_FAIL, _("umount: cannot unmount %s -- %s is "
                                    "mounted over it on the same point"),
                                    file, mc1->m.mnt_fsname);
                        }
+                       free(cn);
                }
        }
        if (!mc && verbose)