tree-wide: replace all remaining uses of parse_env_file() for parsing /proc/cmdline

Let's always go through the proc-cmdline.c APIs.
This commit is contained in:
Lennart Poettering 2018-11-12 13:49:20 +01:00
parent 26a9337690
commit 01771226c2
3 changed files with 34 additions and 36 deletions

View file

@ -16,6 +16,7 @@
#include "fileio.h"
#include "locale-util.h"
#include "pager.h"
#include "proc-cmdline.h"
#include "set.h"
#include "spawn-polkit-agent.h"
#include "strv.h"
@ -53,10 +54,11 @@ static void print_overridden_variables(void) {
LocaleVariable j;
bool print_warning = true;
if (detect_container() > 0 || arg_host)
if (arg_transport != BUS_TRANSPORT_LOCAL)
return;
r = parse_env_file(NULL, "/proc/cmdline", WHITESPACE,
r = proc_cmdline_get_key_many(
PROC_CMDLINE_STRIP_RD_PREFIX,
"locale.LANG", &variables[VARIABLE_LANG],
"locale.LANGUAGE", &variables[VARIABLE_LANGUAGE],
"locale.LC_CTYPE", &variables[VARIABLE_LC_CTYPE],
@ -70,9 +72,7 @@ static void print_overridden_variables(void) {
"locale.LC_ADDRESS", &variables[VARIABLE_LC_ADDRESS],
"locale.LC_TELEPHONE", &variables[VARIABLE_LC_TELEPHONE],
"locale.LC_MEASUREMENT", &variables[VARIABLE_LC_MEASUREMENT],
"locale.LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION],
NULL);
"locale.LC_IDENTIFICATION", &variables[VARIABLE_LC_IDENTIFICATION]);
if (r < 0 && r != -ENOENT) {
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
goto finish;

View file

@ -56,6 +56,7 @@
#include "parse-util.h"
#include "path-lookup.h"
#include "path-util.h"
#include "proc-cmdline.h"
#include "process-util.h"
#include "reboot-util.h"
#include "rlimit-util.h"
@ -5699,9 +5700,7 @@ static int switch_root(int argc, char *argv[], void *userdata) {
if (argc >= 3)
init = argv[2];
else {
r = parse_env_file(NULL, "/proc/cmdline", WHITESPACE,
"init", &cmdline_init,
NULL);
r = proc_cmdline_get_key("init", 0, &cmdline_init);
if (r < 0)
log_debug_errno(r, "Failed to parse /proc/cmdline: %m");

View file

@ -23,6 +23,7 @@
#include "io-util.h"
#include "locale-util.h"
#include "log.h"
#include "proc-cmdline.h"
#include "process-util.h"
#include "signal-util.h"
#include "stdio-util.h"
@ -428,8 +429,8 @@ int main(int argc, char **argv) {
log_warning_errno(r, "Failed to read /etc/vconsole.conf: %m");
/* Let the kernel command line override /etc/vconsole.conf */
if (detect_container() <= 0) {
r = parse_env_file(NULL, "/proc/cmdline", WHITESPACE,
r = proc_cmdline_get_key_many(
PROC_CMDLINE_STRIP_RD_PREFIX,
"vconsole.keymap", &vc_keymap,
"vconsole.keymap_toggle", &vc_keymap_toggle,
"vconsole.font", &vc_font,
@ -438,11 +439,9 @@ int main(int argc, char **argv) {
/* compatibility with obsolete multiple-dot scheme */
"vconsole.keymap.toggle", &vc_keymap_toggle,
"vconsole.font.map", &vc_font_map,
"vconsole.font.unimap", &vc_font_unimap,
NULL);
"vconsole.font.unimap", &vc_font_unimap);
if (r < 0 && r != -ENOENT)
log_warning_errno(r, "Failed to read /proc/cmdline: %m");
}
(void) toggle_utf8_sysfs(utf8);
(void) toggle_utf8(vc, fd, utf8);