diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-11-06 21:53:34 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-11-07 01:19:56 +0100 |
commit | b5884878a2874447b2a9f07f324a7cd909d96d48 (patch) | |
tree | 7187916b29404dad30f53be8ed0393a095571e0d /src/shared/util.c | |
parent | f2997962ff8aeea577bed878d3bc4e4f64784e45 (diff) |
util: simplify proc_cmdline() to reuse get_process_cmdline()
Also, make all parsing of the kernel cmdline non-fatal.
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 35 |
1 files changed, 6 insertions, 29 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index dc1bc39ac7..6401aaf61c 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -6153,11 +6153,8 @@ int shall_restore_state(void) { r = proc_cmdline(&line); if (r < 0) return r; - if (r == 0) /* Container ... */ - return 1; r = 1; - FOREACH_WORD_QUOTED(word, l, line, state) { const char *e; char n[l+1]; @@ -6179,30 +6176,12 @@ int shall_restore_state(void) { } int proc_cmdline(char **ret) { - int r; - - if (detect_container(NULL) > 0) { - char *buf = NULL, *p; - size_t sz = 0; - - r = read_full_file("/proc/1/cmdline", &buf, &sz); - if (r < 0) - return r; - - for (p = buf; p + 1 < buf + sz; p++) - if (*p == 0) - *p = ' '; - - *p = 0; - *ret = buf; - return 1; - } - - r = read_one_line_file("/proc/cmdline", ret); - if (r < 0) - return r; + assert(ret); - return 1; + if (detect_container(NULL) > 0) + return get_process_cmdline(1, 0, false, ret); + else + return read_one_line_file("/proc/cmdline", ret); } int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) { @@ -6215,9 +6194,7 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) { r = proc_cmdline(&line); if (r < 0) - log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r)); - if (r <= 0) - return 0; + return r; FOREACH_WORD_QUOTED(w, l, line, state) { char word[l+1], *value; |