Merge pull request #27618 from DaanDeMeyer/fstab-generator

Fstab generator fixes
This commit is contained in:
Yu Watanabe
2023-05-12 04:23:54 +09:00
committed by GitHub
+19 -7
View File
@@ -60,6 +60,7 @@ static char *arg_usr_fstype = NULL;
static char *arg_usr_options = NULL;
static char *arg_usr_hash = NULL;
static VolatileMode arg_volatile_mode = _VOLATILE_MODE_INVALID;
static bool arg_verity = true;
STATIC_DESTRUCTOR_REGISTER(arg_root_what, freep);
STATIC_DESTRUCTOR_REGISTER(arg_root_fstype, freep);
@@ -1004,7 +1005,7 @@ static int add_sysroot_usr_mount(void) {
}
if (isempty(arg_usr_what)) {
log_debug("Could not find a usr= entry on the kernel command line.");
log_debug("Could not find a mount.usr= entry on the kernel command line.");
return 0;
}
@@ -1140,14 +1141,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
return free_and_strdup_warn(&arg_root_what, value);
return free_and_strdup_warn(&arg_root_what, empty_to_null(value));
} else if (streq(key, "rootfstype")) {
if (proc_cmdline_value_missing(key, value))
return 0;
return free_and_strdup_warn(&arg_root_fstype, value);
return free_and_strdup_warn(&arg_root_fstype, empty_to_null(value));
} else if (streq(key, "rootflags")) {
@@ -1162,21 +1163,21 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
return free_and_strdup_warn(&arg_root_hash, value);
return free_and_strdup_warn(&arg_root_hash, empty_to_null(value));
} else if (streq(key, "mount.usr")) {
if (proc_cmdline_value_missing(key, value))
return 0;
return free_and_strdup_warn(&arg_usr_what, value);
return free_and_strdup_warn(&arg_usr_what, empty_to_null(value));
} else if (streq(key, "mount.usrfstype")) {
if (proc_cmdline_value_missing(key, value))
return 0;
return free_and_strdup_warn(&arg_usr_fstype, value);
return free_and_strdup_warn(&arg_usr_fstype, empty_to_null(value));
} else if (streq(key, "mount.usrflags")) {
@@ -1191,7 +1192,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value))
return 0;
return free_and_strdup_warn(&arg_usr_hash, value);
return free_and_strdup_warn(&arg_usr_hash, empty_to_null(value));
} else if (streq(key, "rw") && !value)
arg_root_rw = true;
@@ -1216,6 +1217,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
log_warning("Failed to parse systemd.swap switch %s. Ignoring.", value);
else
arg_swap_enabled = r;
} else if (streq(key, "systemd.verity")) {
r = value ? parse_boolean(value) : 1;
if (r < 0)
log_warning("Failed to parse systemd.verity= kernel command line switch %s. Ignoring.", value);
else
arg_verity = r;
}
return 0;
@@ -1233,6 +1242,9 @@ static int determine_device(char **what, const char *hash, const char *name) {
if (!hash)
return 0;
if (!arg_verity)
return 0;
*what = path_join("/dev/mapper/", name);
if (!*what)
return log_oom();