summaryrefslogtreecommitdiffstats
path: root/mount/fstab.c
diff options
context:
space:
mode:
authorKarel Zak2009-01-07 00:00:35 +0100
committerKarel Zak2009-01-07 00:00:35 +0100
commitb2cf00d440cff65681a9eecf23e1157fc4104827 (patch)
tree8e8383adbfb6410702d12911199355f01c733889 /mount/fstab.c
parentmount: suggest to use blockdev --setro rather than losetup (diff)
downloadkernel-qcow2-util-linux-b2cf00d440cff65681a9eecf23e1157fc4104827.tar.gz
kernel-qcow2-util-linux-b2cf00d440cff65681a9eecf23e1157fc4104827.tar.xz
kernel-qcow2-util-linux-b2cf00d440cff65681a9eecf23e1157fc4104827.zip
mount: finalize support of quoted LABELs/UUIDs
The [u]mount does not properly support LABEL="foo" or UUID="foo" in /etc/fstab. This patch fix last places where we assume unquoted LABELs/UUIDs only. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'mount/fstab.c')
-rw-r--r--mount/fstab.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/mount/fstab.c b/mount/fstab.c
index 306e7bec7..8e7019a5d 100644
--- a/mount/fstab.c
+++ b/mount/fstab.c
@@ -288,6 +288,16 @@ getmntoptfile (const char *file) {
return NULL;
}
+/* compares "quoted" or 'quoted' with unquoted */
+static int
+streq_quoted(const char *quoted, const char *unquoted)
+{
+ if (*quoted == '"' || *quoted == '\'')
+ return !strncmp(quoted + 1, unquoted, strlen(quoted) - 2);
+
+ return streq(quoted, unquoted);
+}
+
static int
has_label(const char *device, const char *label) {
const char *devlabel;
@@ -297,7 +307,7 @@ has_label(const char *device, const char *label) {
if (!devlabel)
return 0;
- ret = !strcmp(label, devlabel);
+ ret = streq_quoted(label, devlabel);
my_free(devlabel);
return ret;
}
@@ -311,7 +321,7 @@ has_uuid(const char *device, const char *uuid){
if (!devuuid)
return 0;
- ret = !strcmp(uuid, devuuid);
+ ret = streq_quoted(uuid, devuuid);
my_free(devuuid);
return ret;
}
@@ -456,7 +466,7 @@ getfs_by_uuid (const char *uuid) {
mc0 = fstab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
if (strncmp (mc->m.mnt_fsname, "UUID=", 5) == 0
- && streq(mc->m.mnt_fsname + 5, uuid))
+ && streq_quoted(mc->m.mnt_fsname + 5, uuid))
return mc;
return NULL;
}
@@ -469,7 +479,7 @@ getfs_by_label (const char *label) {
mc0 = fstab_head();
for (mc = mc0->nxt; mc && mc != mc0; mc = mc->nxt)
if (strncmp (mc->m.mnt_fsname, "LABEL=", 6) == 0
- && streq(mc->m.mnt_fsname + 6, label))
+ && streq_quoted(mc->m.mnt_fsname + 6, label))
return mc;
return NULL;
}