Re: [PATCH] mount: use canonicalize in getfs_by_devname

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Feb 11, 2008 at 05:04:22PM +0100, Matthias Koenig wrote:
> Matthias Koenig <mkoenig@xxxxxxx> writes:
> 
> > Fixes a problem when you define a device via a persistent
> > udev device name in /etc/fstab but use the real block device
> > name on mount invocation.

 I didn't test it, but according to the code (and code never lies:-)
 you're right.

> >  	mc0 = fstab_head();
> > -	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
> > -		if (streq(mc->m.mnt_fsname, devname))
> > +	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
> > +		name = canonicalize(mc->m.mnt_fsname);
> > +		if (streq(name, devname)) {
> > +			free(name);
> >  			return mc;
> > +		}
> > +		free(name);
> > +	}
> >  	return NULL;
> >  }

 We can't simply canonicalize only. We have to support non-canonicalized
 (/dev/cdrom, ...) versions too. And there shouldn't be a performance
 penalization for people who use canonical paths in their fstab.

> I am dumb, please ignore this patch.
> New patch will follow.

 No problem. Please, test the patch below.

    Karel

>From a3c6d618c332ed3651fef629739ac246fd31b7ca Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@xxxxxxxxxx>
Date: Fri, 15 Feb 2008 01:56:18 +0100
Subject: [PATCH] mount: use canonicalize in getfs_by_devname

Fixes a problem when you define a device via a persistent
udev device name in /etc/fstab but use the real block device
name on mount invocation.

Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 mount/fstab.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/mount/fstab.c b/mount/fstab.c
index 814e6fc..ada8d32 100644
--- a/mount/fstab.c
+++ b/mount/fstab.c
@@ -425,9 +425,22 @@ getfs_by_devname (const char *devname) {
 	struct mntentchn *mc, *mc0;
 
 	mc0 = fstab_head();
+
+	/* canonical devname in fstab */
 	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
 		if (streq(mc->m.mnt_fsname, devname))
 			return mc;
+
+	/* noncanonical devname in fstab */
+	for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) {
+		char *fs = canonicalize(mc->m.mnt_fsname);
+		if (streq(fs, devname)) {
+			free(fs);
+			return mc;
+		}
+		free(fs);
+	}
+
 	return NULL;
 }
 
-- 
1.5.3.8

-
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux