diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-11-12 03:04:10 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-11-12 03:04:10 +0100 |
commit | 74715b82cb6a09e10ba3fbd2146cd3285f5e6544 (patch) | |
tree | a42200a268229e7744a3ec7e2111c035f8429664 /src | |
parent | f41c094c9fb6760b27996aacfe1e66f2f2f415cb (diff) |
cryptsetup: automatically start cryptsetup when looking for mount source
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptsetup-generator.c | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/src/cryptsetup-generator.c b/src/cryptsetup-generator.c index 73c367935f..d1d7bb6954 100644 --- a/src/cryptsetup-generator.c +++ b/src/cryptsetup-generator.c @@ -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); |