mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
Merge pull request #28727 from yuwata/proc-cmdline-cleanups
tree-wide: fixlet and optimization for parsing kernel command line
This commit is contained in:
@@ -1355,6 +1355,8 @@ static int add_mounts_from_creds(bool prefix_sysroot) {
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
assert(key);
|
||||
|
||||
/* root=, usr=, usrfstype= and roofstype= may occur more than once, the last
|
||||
* instance should take precedence. In the case of multiple rootflags=
|
||||
* or usrflags= the arguments should be concatenated */
|
||||
|
||||
@@ -904,7 +904,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
else
|
||||
arg_enabled = r;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "root")) {
|
||||
} else if (streq(key, "root")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
@@ -917,7 +917,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
log_debug("Disabling root partition auto-detection, root= is defined.");
|
||||
}
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "roothash")) {
|
||||
} else if (streq(key, "roothash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
@@ -941,14 +941,14 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (!strextend_with_separator(&arg_root_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "rw") && !value)
|
||||
} else if (streq(key, "rw") && !value)
|
||||
arg_root_rw = true;
|
||||
else if (proc_cmdline_key_streq(key, "ro") && !value)
|
||||
else if (streq(key, "ro") && !value)
|
||||
arg_root_rw = false;
|
||||
else if (proc_cmdline_key_streq(key, "systemd.image_policy"))
|
||||
return parse_image_policy_argument(optarg, &arg_image_policy);
|
||||
|
||||
else if (proc_cmdline_key_streq(key, "systemd.swap")) {
|
||||
else if (streq(key, "systemd.swap")) {
|
||||
|
||||
r = value ? parse_boolean(value) : 1;
|
||||
if (r < 0)
|
||||
|
||||
@@ -56,7 +56,9 @@ typedef struct EFIHibernateLocation {
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
if (proc_cmdline_key_streq(key, "resume")) {
|
||||
assert(key);
|
||||
|
||||
if (streq(key, "resume")) {
|
||||
char *s;
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
@@ -79,7 +81,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
|
||||
arg_resume_offset_set = true;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "resumeflags")) {
|
||||
} else if (streq(key, "resumeflags")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
@@ -87,7 +89,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (!strextend_with_separator(&arg_resume_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "rootflags")) {
|
||||
} else if (streq(key, "rootflags")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
@@ -95,7 +97,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (!strextend_with_separator(&arg_root_options, ",", value))
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "noresume")) {
|
||||
} else if (streq(key, "noresume")) {
|
||||
|
||||
if (value) {
|
||||
log_warning("\"noresume\" kernel command line switch specified with an argument, ignoring.");
|
||||
return 0;
|
||||
|
||||
@@ -512,12 +512,17 @@ static int proc_cmdline_callback(const char *key, const char *value, void *data)
|
||||
struct ProcCmdlineInfo *info = ASSERT_PTR(data);
|
||||
int r;
|
||||
|
||||
assert(key);
|
||||
assert(info->manager);
|
||||
|
||||
/* The kernel command line option names are chosen to be compatible with what various tools already
|
||||
* interpret, for example dracut and SUSE Linux. */
|
||||
|
||||
if (proc_cmdline_key_streq(key, "nameserver")) {
|
||||
if (streq(key, "nameserver")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
if (!info->dns_server_unlinked) {
|
||||
/* The kernel command line overrides any prior configuration */
|
||||
dns_server_unlink_all(manager_get_first_dns_server(info->manager, DNS_SERVER_SYSTEM));
|
||||
@@ -530,7 +535,10 @@ static int proc_cmdline_callback(const char *key, const char *value, void *data)
|
||||
|
||||
info->manager->read_resolv_conf = false;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "domain")) {
|
||||
} else if (streq(key, "domain")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
if (!info->search_domain_unlinked) {
|
||||
dns_search_domain_unlink_all(info->manager->search_domains);
|
||||
|
||||
@@ -26,7 +26,9 @@ STATIC_DESTRUCTOR_REGISTER(arg_failure_action, freep);
|
||||
static int parse(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
if (proc_cmdline_key_streq(key, "systemd.run")) {
|
||||
assert(key);
|
||||
|
||||
if (streq(key, "systemd.run")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
@@ -136,7 +136,9 @@ static int create_usr_device(void) {
|
||||
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
|
||||
int r;
|
||||
|
||||
if (proc_cmdline_key_streq(key, "systemd.verity")) {
|
||||
assert(key);
|
||||
|
||||
if (streq(key, "systemd.verity")) {
|
||||
|
||||
r = value ? parse_boolean(value) : 1;
|
||||
if (r < 0)
|
||||
@@ -152,7 +154,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
else
|
||||
arg_read_veritytab = r;
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "roothash")) {
|
||||
} else if (streq(key, "roothash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
@@ -188,7 +190,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (r < 0)
|
||||
return log_oom();
|
||||
|
||||
} else if (proc_cmdline_key_streq(key, "usrhash")) {
|
||||
} else if (streq(key, "usrhash")) {
|
||||
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user