summaryrefslogtreecommitdiff
path: root/src/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-11-07 23:02:45 -0500
committerLennart Poettering <lennart@poettering.net>2010-11-10 22:38:43 +0100
commite23a0ce8badd09aefa961a3a576bfe85f6ebbad7 (patch)
tree146fa8975cd6ebf899b79fd66d9af678242e9d35 /src/util.c
parent1829dc9dc5f38cd1aaa43912de56c3bb5d8b5617 (diff)
cryptsetup: minimal cryptsetup unit generator
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
index fecdee12e2..6f9399b418 100644
--- a/src/util.c
+++ b/src/util.c
@@ -3566,6 +3566,57 @@ void dual_timestamp_deserialize(const char *value, dual_timestamp *t) {
}
}
+
+char *fstab_node_to_udev_node(const char *p) {
+ 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;
+ }
+
+ if (startswith(p, "UUID=")) {
+
+ 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));
+ free(t);
+
+ if (r < 0)
+ return NULL;
+
+ return dn;
+ }
+
+ return strdup(p);
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",