diff options
author | Karel Zak | 2011-04-11 14:05:57 +0200 |
---|---|---|
committer | Karel Zak | 2011-04-11 14:05:57 +0200 |
commit | 531019d5c358bead52adb2cfce0eb92544d722de (patch) | |
tree | a1e6c4c9d95e513c38d0931d07a8dd20562b06f0 /mount | |
parent | docs: update TODO (diff) | |
download | kernel-qcow2-util-linux-531019d5c358bead52adb2cfce0eb92544d722de.tar.gz kernel-qcow2-util-linux-531019d5c358bead52adb2cfce0eb92544d722de.tar.xz kernel-qcow2-util-linux-531019d5c358bead52adb2cfce0eb92544d722de.zip |
umount: support non-canonical devnames in mtab
Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/755193
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount')
-rw-r--r-- | mount/fstab.c | 13 | ||||
-rw-r--r-- | mount/umount.c | 5 |
2 files changed, 17 insertions, 1 deletions
diff --git a/mount/fstab.c b/mount/fstab.c index 32b8dac18..fd53ca4be 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -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; } diff --git a/mount/umount.c b/mount/umount.c index 2e7bd31ce..add6c87da 100644 --- a/mount/umount.c +++ b/mount/umount.c @@ -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) |