#include "util.h"
#include "unit-name.h"
#include "mkdir.h"
-#include "virt.h"
#include "strv.h"
#include "fileio.h"
"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);
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))
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;