chiark / gitweb /
mount: properly handle LABEL="" in fstab
authorLennart Poettering <lennart@poettering.net>
Fri, 20 Aug 2010 00:46:15 +0000 (02:46 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 20 Aug 2010 00:46:15 +0000 (02:46 +0200)
fixme
src/mount.c
src/util.c
src/util.h

diff --git a/fixme b/fixme
index b1474f5246d06b74364e27f164f9586a5de8c1ee..b43a10213048436245fe31eb1d0cc81211f74f1a 100644 (file)
--- a/fixme
+++ b/fixme
@@ -60,8 +60,6 @@
 
 * bash completion a la gdbus
 
-* fstab mit tüdelchen
-
 * api mounts gegen fstab mergen und remounten
 
 External:
index e0ca5bb5d0dd16f4a015282503dc7aa6c167592e..ac33787e61e42c8307a3386419dcc7056b566a1d 100644 (file)
@@ -1175,7 +1175,7 @@ fail:
 }
 
 static char *fstab_node_to_udev_node(char *p) {
-        char *dn, *t;
+        char *dn, *t, *u;
         int r;
 
         /* FIXME: to follow udev's logic 100% we need to leave valid
@@ -1183,7 +1183,13 @@ static char *fstab_node_to_udev_node(char *p) {
 
         if (startswith(p, "LABEL=")) {
 
-                if (!(t = xescape(p+6, "/ ")))
+                if (!(u = unquote(p+6, '"')))
+                        return NULL;
+
+                t = xescape(u, "/ ");
+                free(u);
+
+                if (!t)
                         return NULL;
 
                 r = asprintf(&dn, "/dev/disk/by-label/%s", t);
@@ -1197,7 +1203,13 @@ static char *fstab_node_to_udev_node(char *p) {
 
         if (startswith(p, "UUID=")) {
 
-                if (!(t = xescape(p+5, "/ ")))
+                if (!(u = unquote(p+5, '"')))
+                        return NULL;
+
+                t = xescape(u, "/ ");
+                free(u);
+
+                if (!t)
                         return NULL;
 
                 r = asprintf(&dn, "/dev/disk/by-uuid/%s", ascii_strlower(t));
index 7903ca07b99fe64d493948f579eb9e34f3adbd31..f1a7bbdc7124b1d977d536fcb4c83bea80213478 100644 (file)
@@ -3004,6 +3004,19 @@ int touch(const char *path) {
         return 0;
 }
 
+char *unquote(const char *s, const char quote) {
+        size_t l;
+        assert(s);
+
+        if ((l = strlen(s)) < 2)
+                return strdup(s);
+
+        if (s[0] == quote && s[l-1] == quote)
+                return strndup(s+1, l-2);
+
+        return strdup(s);
+}
+
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",
index 7490236fa0915e4abaf678c818dadd1864278c9f..4063ee7ff276b82b8b1f28d78f4decd4cccbef02 100644 (file)
@@ -339,6 +339,8 @@ char *ellipsize(const char *s, unsigned length, unsigned percent);
 
 int touch(const char *path);
 
+char *unquote(const char *s, const char quote);
+
 #define NULSTR_FOREACH(i, l) \
         for ((i) = (l); (i) && *(i); (i) = strchr((i), 0)+1)