From: Karel Zak Date: Mon, 28 May 2007 11:20:27 +0000 (+0200) Subject: mount: getfs_* (fstab) interface has to work with canonicalize() X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c20767edf408882e06abc0eb3b75e4dd41581d6f;p=util-linux mount: getfs_* (fstab) interface has to work with canonicalize() The getfs_by_dir() and getfs_by_devname() have to be able to work with canonicalized and also with non-canonicalized paths. Signed-off-by: Karel Zak --- diff --git a/mount/fstab.c b/mount/fstab.c index b7792bc0..e869abf4 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -358,18 +358,28 @@ getfs_by_specdir (const char *spec, const char *dir) { struct mntentchn * getfs_by_dir (const char *dir) { struct mntentchn *mc, *mc0; + char *cdir; mc0 = fstab_head(); for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) if (streq(mc->m.mnt_dir, dir)) return mc; + + cdir = canonicalize(dir); + for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt) { + if (streq(mc->m.mnt_dir, cdir)) { + free(cdir); + return mc; + } + } + free(cdir); return NULL; } /* Find the device SPEC in fstab. */ struct mntentchn * getfs_by_spec (const char *spec) { - char *name, *value; + char *name, *value, *cspec; struct mntentchn *mc = NULL; if (!spec) @@ -387,7 +397,16 @@ getfs_by_spec (const char *spec) { free((void *) name); return mc; } - return getfs_by_devname(spec); + + cspec = canonicalize(spec); + mc = getfs_by_devname(cspec); + free(cspec); + + if (!mc) + /* noncanonical name like /dev/cdrom */ + mc = getfs_by_devname(spec); + + return mc; } /* Find the device in fstab. */