summaryrefslogtreecommitdiff
path: root/src/cryptsetup-generator.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-11-18 02:16:36 +0100
committerLennart Poettering <lennart@poettering.net>2010-11-18 02:16:36 +0100
commit2f8cd170aeb0d748f5af3cefb387d14f67fc286e (patch)
tree654b61e180fddba749e36087771f02c0e7d8e754 /src/cryptsetup-generator.c
parent21931dbe6561047a6fe728dc38cd2d6468066e5a (diff)
cryptsetup: automatically order crypt partitions before cryptsetup.target
Diffstat (limited to 'src/cryptsetup-generator.c')
-rw-r--r--src/cryptsetup-generator.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/cryptsetup-generator.c b/src/cryptsetup-generator.c
index a2b398dd15..c5e54d0988 100644
--- a/src/cryptsetup-generator.c
+++ b/src/cryptsetup-generator.c
@@ -102,7 +102,7 @@ static int create_disk(
"DefaultDependencies=no\n"
"BindTo=%s dev-mapper-%%i.device\n"
"After=systemd-readahead-collect.service systemd-readahead-replay.service %s\n"
- "Before=dev-mapper-%%i.device shutdown.target local-fs.target\n",
+ "Before=dev-mapper-%%i.device shutdown.target cryptsetup.target\n",
d, d);
if (password && (streq(password, "/dev/urandom") ||
@@ -157,6 +157,25 @@ static int create_disk(
r = -errno;
goto fail;
}
+
+ free(to);
+ to = NULL;
+
+ if (!options || !has_option(options, "nofail")) {
+
+ if (asprintf(&to, "%s/cryptsetup.target.wants/%s", arg_dest, 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;
+ }
+ }
}
free(to);