From: Lennart Poettering Date: Wed, 21 Dec 2022 08:47:46 +0000 (+0100) Subject: gpt-auto-generator: honour rootfstype= and rootflags= kernel cmdline option X-Git-Tag: v253-rc1~230 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf451f382a6ebf6ad34b36939ed4f8dee1c04e61;p=thirdparty%2Fsystemd.git gpt-auto-generator: honour rootfstype= and rootflags= kernel cmdline option Even if root= is not specified on the kernel cmdline, we should honour the other rootXYZ= options. Fixes: #8411 See: #17034 --- diff --git a/man/kernel-command-line.xml b/man/kernel-command-line.xml index fcab0a90f40..545dc40798a 100644 --- a/man/kernel-command-line.xml +++ b/man/kernel-command-line.xml @@ -336,11 +336,16 @@ rw - Configures the root file system and its file system - type and mount options, as well as whether it shall be - mounted read-only or read-write initially. For details, - see + Configures the root file system and its file system type and mount options, as well as + whether it shall be mounted read-only or read-write initially. For details, see systemd-fstab-generator8. + + If root= is not set (or set to gpt-auto) the automatic + root partition discovery implemented by + systemd-gpt-auto-generator8 + will be in effect. In this case rootfstype=, rootflags=, + ro, rw will be interpreted by + systemd-gpt-auto-generator. diff --git a/man/systemd-gpt-auto-generator.xml b/man/systemd-gpt-auto-generator.xml index 3b166b87f90..4ccc80994d0 100644 --- a/man/systemd-gpt-auto-generator.xml +++ b/man/systemd-gpt-auto-generator.xml @@ -244,10 +244,16 @@ root= + rootfstype= + rootflags= - When used with the special value gpt-auto, automatic discovery of - the root partition based on the GPT partition type is enabled. Any other value disables this - generator. + When root= is used with the special value + gpt-auto (or if the parameter is not used at all), automatic discovery of the root + partition based on the GPT partition type is enabled. Any other value disables this + logic. + + The rootfstype= and rootflags= are used to select the + file system type and options when the root file system is automatically discovered. diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index f2f6cc1a53d..d697a9b362c 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -40,8 +40,13 @@ static const char *arg_dest = NULL; static bool arg_enabled = true; static bool arg_root_enabled = true; +static char *arg_root_fstype = NULL; +static char *arg_root_options = NULL; static int arg_root_rw = -1; +STATIC_DESTRUCTOR_REGISTER(arg_root_fstype, freep); +STATIC_DESTRUCTOR_REGISTER(arg_root_options, freep); + static int add_cryptsetup( const char *id, const char *what, @@ -622,10 +627,10 @@ static int add_root_mount(void) { "root", "/dev/gpt-auto-root", in_initrd() ? "/sysroot" : "/", - NULL, + arg_root_fstype, /* rw= */ arg_root_rw > 0, /* growfs= */ false, - NULL, + arg_root_options, "Root Partition", in_initrd() ? SPECIAL_INITRD_ROOT_FS_TARGET : SPECIAL_LOCAL_FS_TARGET); #else @@ -801,6 +806,21 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat arg_root_enabled = false; + } else if (streq(key, "rootfstype")) { + + if (proc_cmdline_value_missing(key, value)) + return 0; + + return free_and_strdup_warn(&arg_root_fstype, value); + + } else if (streq(key, "rootflags")) { + + if (proc_cmdline_value_missing(key, value)) + return 0; + + if (!strextend_with_separator(&arg_root_options, ",", value)) + return log_oom(); + } else if (proc_cmdline_key_streq(key, "rw") && !value) arg_root_rw = true; else if (proc_cmdline_key_streq(key, "ro") && !value)