[systemd-commits] 2 commits - src/shared
Lennart Poettering
lennart at kemper.freedesktop.org
Tue Aug 21 09:59:02 PDT 2012
src/shared/util.c | 54 +++++++++++++++++++++++-------------------------------
1 file changed, 23 insertions(+), 31 deletions(-)
New commits:
commit 84cc2abf3472b6dddd54b046b24f559ec8807ee4
Author: Dave Reisner <dreisner at archlinux.org>
Date: Sat Aug 11 13:32:29 2012 -0400
shared/util: add fstab support for partuuid/partlabel
udev has supported this since 172, so it should be a safe (and welcome)
addition for users of GPT partitioned disks.
diff --git a/src/shared/util.c b/src/shared/util.c
index d94bc69..55e344f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4159,6 +4159,12 @@ char *fstab_node_to_udev_node(const char *p) {
if (startswith(p, "UUID="))
return tag_to_udev_node(p+5, "uuid");
+ if (startswith(p, "PARTUUID="))
+ return tag_to_udev_node(p+9, "partuuid");
+
+ if (startswith(p, "PARTLABEL="))
+ return tag_to_udev_node(p+10, "partlabel");
+
return strdup(p);
}
commit 383182b5c435dca06a3f4ba32c6d1be2d1e35881
Author: Dave Reisner <dreisner at archlinux.org>
Date: Sat Aug 11 13:31:50 2012 -0400
shared/util: refactor fstab_node_to_udev_node
Since this is purely duplicated logic, separate it out into a small
static function.
diff --git a/src/shared/util.c b/src/shared/util.c
index 736cb15..d94bc69 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -4126,52 +4126,38 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
}
}
-char *fstab_node_to_udev_node(const char *p) {
+static char *tag_to_udev_node(const char *tagvalue, const char *by) {
char *dn, *t, *u;
int r;
/* FIXME: to follow udev's logic 100% we need to leave valid
* UTF8 chars unescaped */
- if (startswith(p, "LABEL=")) {
-
- 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);
- free(t);
-
- if (r < 0)
- return NULL;
-
- return dn;
- }
+ u = unquote(tagvalue, "\"\'");
+ if (u == NULL)
+ return NULL;
- if (startswith(p, "UUID=")) {
+ t = xescape(u, "/ ");
+ free(u);
- if (!(u = unquote(p+5, "\"\'")))
- return NULL;
+ if (t == NULL)
+ return NULL;
- t = xescape(u, "/ ");
- free(u);
+ r = asprintf(&dn, "/dev/disk/by-%s/%s", by, t);
+ free(t);
- if (!t)
- return NULL;
+ if (r < 0)
+ return NULL;
- r = asprintf(&dn, "/dev/disk/by-uuid/%s", t);
- free(t);
+ return dn;
+}
- if (r < 0)
- return NULL;
+char *fstab_node_to_udev_node(const char *p) {
+ if (startswith(p, "LABEL="))
+ return tag_to_udev_node(p+6, "label");
- return dn;
- }
+ if (startswith(p, "UUID="))
+ return tag_to_udev_node(p+5, "uuid");
return strdup(p);
}
More information about the systemd-commits
mailing list