mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 02:21:44 +03:00
proc-cmdline: teach proc_cmdline_get_key() the same flags magic as proc_cmdline_parse()
This commit is contained in:
parent
cb447ff5cc
commit
7d95229ba7
@ -159,7 +159,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
|
||||
p = line;
|
||||
for (;;) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
const char *e;
|
||||
const char *e, *k, *q;
|
||||
|
||||
r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
|
||||
if (r < 0)
|
||||
@ -167,13 +167,23 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
|
||||
if (r == 0)
|
||||
break;
|
||||
|
||||
k = word;
|
||||
|
||||
/* Automatically filter out arguments that are intended only for the initrd, if we are not in the
|
||||
* initrd. */
|
||||
if (!in_initrd() && startswith(word, "rd."))
|
||||
q = startswith(word, "rd.");
|
||||
if (q) {
|
||||
if (!in_initrd())
|
||||
continue;
|
||||
|
||||
if (FLAGS_SET(flags, PROC_CMDLINE_STRIP_RD_PREFIX))
|
||||
k = q;
|
||||
|
||||
} else if (FLAGS_SET(flags, PROC_CMDLINE_RD_STRICT) && in_initrd())
|
||||
continue;
|
||||
|
||||
if (value) {
|
||||
e = proc_cmdline_key_startswith(word, key);
|
||||
e = proc_cmdline_key_startswith(k, key);
|
||||
if (!e)
|
||||
continue;
|
||||
|
||||
@ -188,7 +198,7 @@ int proc_cmdline_get_key(const char *key, unsigned flags, char **value) {
|
||||
found = true;
|
||||
|
||||
} else {
|
||||
if (streq(word, key))
|
||||
if (streq(k, key))
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user