mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
fstab-generator: use 'usr' mapper device when 'usrhash' is present
If 'usrhash' is present as a kernel command line parameter, use the usr mapper device for usr mount
This commit is contained in:
parent
78b408d2d9
commit
c1b9e3dffe
@ -50,6 +50,7 @@ static int arg_root_rw = -1;
|
||||
static char *arg_usr_what = NULL;
|
||||
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_DESTRUCTOR_REGISTER(arg_root_what, freep);
|
||||
@ -59,6 +60,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_root_hash, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_usr_what, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_usr_fstype, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_usr_options, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_usr_hash, freep);
|
||||
|
||||
static int write_options(FILE *f, const char *options) {
|
||||
_cleanup_free_ char *o = NULL;
|
||||
@ -969,6 +971,13 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (!strextend_with_separator(&arg_usr_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (streq(key, "usrhash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
return free_and_strdup_warn(&arg_usr_hash, value);
|
||||
|
||||
} else if (streq(key, "rw") && !value)
|
||||
arg_root_rw = true;
|
||||
else if (streq(key, "ro") && !value)
|
||||
@ -997,24 +1006,35 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int determine_root(void) {
|
||||
/* If we have a root hash but no root device then Verity is used, and we use the "root" DM device as root. */
|
||||
static int determine_device(char **what, const char *hash, const char *name) {
|
||||
|
||||
if (arg_root_what)
|
||||
assert(what);
|
||||
assert(name);
|
||||
|
||||
/* If we have a hash but no device then Verity is used, and we use the DM device. */
|
||||
if (*what)
|
||||
return 0;
|
||||
|
||||
if (!arg_root_hash)
|
||||
if (!hash)
|
||||
return 0;
|
||||
|
||||
arg_root_what = strdup("/dev/mapper/root");
|
||||
if (!arg_root_what)
|
||||
*what = path_join("/dev/mapper/", name);
|
||||
if (!*what)
|
||||
return log_oom();
|
||||
|
||||
log_info("Using verity root device %s.", arg_root_what);
|
||||
log_info("Using verity %s device %s.", name, *what);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int determine_root(void) {
|
||||
return determine_device(&arg_root_what, arg_root_hash, "root");
|
||||
}
|
||||
|
||||
static int determine_usr(void) {
|
||||
return determine_device(&arg_usr_what, arg_usr_hash, "usr");
|
||||
}
|
||||
|
||||
static int run(const char *dest, const char *dest_early, const char *dest_late) {
|
||||
int r, r2 = 0, r3 = 0;
|
||||
|
||||
@ -1026,6 +1046,7 @@ static int run(const char *dest, const char *dest_early, const char *dest_late)
|
||||
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
|
||||
|
||||
(void) determine_root();
|
||||
(void) determine_usr();
|
||||
|
||||
/* Always honour root= and usr= in the kernel command line if we are in an initrd */
|
||||
if (in_initrd()) {
|
||||
|
Loading…
Reference in New Issue
Block a user