On Fri, Apr 08, 2011 at 10:46:47PM -0400, Phillip Susi wrote: > If you mount a device-mapper device, /dev/dm-7, and then try to umount The device has not been mounted by mount(8), right? It seems that we are talking about /sbin/mount.ntfs. > /dev/dm-7, it fails saying that is not mounted. This appears to be Fixed, see the patch below. Note that mount(8) canonicalizes all device names, so /dev/dm-N is always translated to /dev/mapper/<name>. In the mtab should be stored the /dev/mapper/<name> paths only. The /dev/dm-N names are private for DM and should not be used in userspace for normal operations. All utils which use the /dev/dm-N format for DM devices (in output or in files like mtab) should be FIXED. Karel >From 531019d5c358bead52adb2cfce0eb92544d722de Mon Sep 17 00:00:00 2001 From: Karel Zak <kzak@xxxxxxxxxx> Date: Mon, 11 Apr 2011 14:05:57 +0200 Subject: [PATCH] umount: support non-canonical devnames in mtab Addresses: https://bugs.launchpad.net/ubuntu/+source/util-linux/+bug/755193 Signed-off-by: Karel Zak <kzak@xxxxxxxxxx> --- mount/fstab.c | 13 +++++++++++++ mount/umount.c | 5 ++++- 2 files changed, 17 insertions(+), 1 deletions(-) diff --git a/mount/fstab.c b/mount/fstab.c index 32b8dac..fd53ca4 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 2e7bd31..add6c87 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) -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html