summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-11-14 14:34:25 -0500
committerAnthony G. Basile <blueness@gentoo.org>2014-11-14 14:34:25 -0500
commit71f9ca7cef18887efc189277b8e78b88ff1d4ea6 (patch)
tree1c3c01de302dbfacd4bdf2777a59bc267e19a185 /src/shared
parent5ce04ca64c9cab96901f3eb6f6000aabf5d17e43 (diff)
util: simplify proc_cmdline() to reuse get_process_cmdline()
Also, make all parsing of the kernel cmdline non-fatal. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/util.c28
1 files changed, 5 insertions, 23 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 6c368b61bb..9721779b4b 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1318,30 +1318,12 @@ void *xbsearch_r(const void *key, const void *base, size_t nmemb, size_t size,
}
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 getpeercred(int fd, struct ucred *ucred) {