chiark / gitweb /
sd-rtnl: do not require ifindex to be set for SETLINK messages
[elogind.git] / src / cryptsetup / cryptsetup-generator.c
index 8792e6b1f53650db7c9141159a95eb91673363c9..46ad9b8d6004f15cf84155b29839c36ee461fb13 100644 (file)
@@ -27,7 +27,6 @@
 #include "util.h"
 #include "unit-name.h"
 #include "mkdir.h"
-#include "virt.h"
 #include "strv.h"
 #include "fileio.h"
 
@@ -118,6 +117,7 @@ static int create_disk(
                 "Conflicts=umount.target\n"
                 "DefaultDependencies=no\n"
                 "BindsTo=dev-mapper-%i.device\n"
+                "IgnoreOnIsolate=true\n"
                 "After=systemd-readahead-collect.service systemd-readahead-replay.service\n",
                 f);
 
@@ -130,11 +130,21 @@ static int create_disk(
                     streq(password, "/dev/random") ||
                     streq(password, "/dev/hw_random"))
                         fputs("After=systemd-random-seed.service\n", f);
-                else if (!streq(password, "-") &&
-                         !streq(password, "none"))
-                        fprintf(f,
-                                "RequiresMountsFor=%s\n",
-                                password);
+
+                else if (!streq(password, "-") && !streq(password, "none")) {
+                        _cleanup_free_ char *uu = fstab_node_to_udev_node(password);
+                        if (uu == NULL)
+                                return log_oom();
+
+                        if (is_device_path(uu)) {
+                                _cleanup_free_ char *dd = unit_name_from_path(uu, ".device");
+                                if (dd == NULL)
+                                        return log_oom();
+
+                                fprintf(f, "After=%1$s\nRequires=%1$s\n", dd);
+                        } else
+                                fprintf(f, "RequiresMountsFor=%s\n", password);
+                }
         }
 
         if (is_device_path(u))
@@ -240,20 +250,21 @@ static int create_disk(
         return 0;
 }
 
-static int parse_proc_cmdline(char ***arg_proc_cmdline_disks, char ***arg_proc_cmdline_options, char **arg_proc_cmdline_keyfile) {
+static int parse_proc_cmdline(
+                char ***arg_proc_cmdline_disks,
+                char ***arg_proc_cmdline_options,
+                char **arg_proc_cmdline_keyfile) {
+
         _cleanup_free_ char *line = NULL;
         char *w = NULL, *state = NULL;
-        int r;
         size_t l;
+        int r;
 
-        if (detect_container(NULL) > 0)
-                return 0;
-
-        r = read_one_line_file("/proc/cmdline", &line);
-        if (r < 0) {
+        r = proc_cmdline(&line);
+        if (r < 0)
                 log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+        if (r <= 0)
                 return 0;
-        }
 
         FOREACH_WORD_QUOTED(w, l, line, state) {
                 _cleanup_free_ char *word = NULL;