summaryrefslogtreecommitdiff
path: root/src/basic/proc-cmdline.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-10-24 17:20:37 +0200
committerGitHub <noreply@github.com>2016-10-24 17:20:37 +0200
commit229ba9fd57942fb7d1bb738ab1ad21356431d952 (patch)
tree8ac955e41a5b655d64b594b684bc9b0d3c5021e7 /src/basic/proc-cmdline.c
parent9b3313d678a4f666e9ddc086a8e92652c9294411 (diff)
parentd7f69e16f1a5b84e9acf1771a9b53da3787ae79d (diff)
Merge pull request #4459 from keszybz/commandline-parsing
Commandline parsing simplification and udev fix
Diffstat (limited to 'src/basic/proc-cmdline.c')
-rw-r--r--src/basic/proc-cmdline.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c
index 0430beadaa..8297a222b7 100644
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -42,7 +42,9 @@ int proc_cmdline(char **ret) {
return read_one_line_file("/proc/cmdline", ret);
}
-int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
+int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value, void *data),
+ void *data,
+ bool strip_prefix) {
_cleanup_free_ char *line = NULL;
const char *p;
int r;
@@ -56,7 +58,7 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
p = line;
for (;;) {
_cleanup_free_ char *word = NULL;
- char *value = NULL;
+ char *value = NULL, *unprefixed;
r = extract_first_word(&p, &word, NULL, EXTRACT_QUOTES|EXTRACT_RELAX);
if (r < 0)
@@ -66,14 +68,15 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
/* Filter out arguments that are intended only for the
* initrd */
- if (!in_initrd() && startswith(word, "rd."))
+ unprefixed = startswith(word, "rd.");
+ if (unprefixed && !in_initrd())
continue;
value = strchr(word, '=');
if (value)
*(value++) = 0;
- r = parse_item(word, value);
+ r = parse_item(strip_prefix && unprefixed ? unprefixed : word, value, data);
if (r < 0)
return r;
}