chiark / gitweb /
cryptsetup: automatically start cryptsetup when looking for mount source
authorLennart Poettering <lennart@poettering.net>
Fri, 12 Nov 2010 02:04:10 +0000 (03:04 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Nov 2010 02:04:10 +0000 (03:04 +0100)
TODO
src/cryptsetup-generator.c

diff --git a/TODO b/TODO
index 1390471..119de40 100644 (file)
--- a/TODO
+++ b/TODO
@@ -84,6 +84,8 @@
 
 * fsck-root.service/start gets queued twice
 
+* tmpfiles: allow specification of .conf files on cmdline
+
 External:
 
 * patch kernel for xattr support in /dev, /proc/, /sys and /sys/fs/cgroup.
index 73c3679..d1d7bb6 100644 (file)
@@ -59,7 +59,7 @@ static int create_disk(
                 const char *password,
                 const char *options) {
 
-        char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL;
+        char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL;
         int r;
         FILE *f = NULL;
 
@@ -139,6 +139,11 @@ static int create_disk(
                 goto fail;
         }
 
+        if (asprintf(&from, "../%s", n) < 0) {
+                r = -ENOMEM;
+                goto fail;
+        }
+
         if (!options || !has_option(options, "noauto")) {
 
                 if (asprintf(&to, "%s/%s.wants/%s", arg_dest, d, n) < 0) {
@@ -146,11 +151,6 @@ static int create_disk(
                         goto fail;
                 }
 
-                if (asprintf(&from, "../%s", n) < 0) {
-                        r = -ENOMEM;
-                        goto fail;
-                }
-
                 mkdir_parents(to, 0755);
 
                 if (symlink(from, to) < 0) {
@@ -160,12 +160,30 @@ static int create_disk(
                 }
         }
 
+        free(to);
+        to = NULL;
+
+        e = unit_name_escape(name);
+        if (asprintf(&to, "%s/dev-mapper-%s.device.wants/%s", arg_dest, e, n) < 0) {
+                r = -ENOMEM;
+                goto fail;
+        }
+
+        mkdir_parents(to, 0755);
+
+        if (symlink(from, to) < 0) {
+                log_error("Failed to create symlink '%s' to '%s': %m", from, to);
+                r = -errno;
+                goto fail;
+        }
+
         r = 0;
 
 fail:
         free(p);
         free(n);
         free(d);
+        free(e);
 
         free(from);
         free(to);