From: Karel Zak Date: Fri, 25 May 2007 10:28:49 +0000 (+0200) Subject: mount: parse SPEC before search in fstab X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcea2252572bfecd002500cc8d0e2f3fd807ebdd;p=util-linux mount: parse SPEC before search in fstab The mount blindly uses a SPEC from command line and tries to found the SPEC in /etc/fstab. It's better to parse the SPEC and search by UUID, LABEL or devname only. Signed-off-by: Karel Zak --- diff --git a/mount/fstab.c b/mount/fstab.c index ec5a9655..b7792bc0 100644 --- a/mount/fstab.c +++ b/mount/fstab.c @@ -369,6 +369,24 @@ getfs_by_dir (const char *dir) { /* Find the device SPEC in fstab. */ struct mntentchn * getfs_by_spec (const char *spec) { + char *name, *value; + struct mntentchn *mc = NULL; + + if (!spec) + return NULL; + + if (parse_spec(spec, &name, &value) != 0) + return NULL; /* parse error */ + + if (name) { + if (!strcmp(name,"LABEL")) + mc = getfs_by_label (value); + else if (!strcmp(name,"UUID")) + mc = getfs_by_uuid (value); + + free((void *) name); + return mc; + } return getfs_by_devname(spec); }