tree-wide: allow state to be passed through to parse_proc_cmdline_item

No functional change.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2016-10-22 14:24:52 -04:00
parent 863a5610c7
commit 96287a4916
14 changed files with 30 additions and 27 deletions

View File

@ -967,7 +967,7 @@ int log_set_max_level_from_string(const char *e) {
return 0;
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
/*
* The systemd.log_xyz= settings are parsed by all tools, and
@ -1012,7 +1012,7 @@ void log_parse_environment(void) {
/* Only try to read the command line in daemons.
We assume that anything that has a controlling
tty is user stuff. */
(void) parse_proc_cmdline(parse_proc_cmdline_item);
(void) parse_proc_cmdline(parse_proc_cmdline_item, NULL);
e = secure_getenv("SYSTEMD_LOG_TARGET");
if (e && log_set_target_from_string(e) < 0)

View File

@ -42,7 +42,7 @@ 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) {
_cleanup_free_ char *line = NULL;
const char *p;
int r;
@ -73,7 +73,7 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
if (value)
*(value++) = 0;
r = parse_item(word, value);
r = parse_item(word, value, data);
if (r < 0)
return r;
}

View File

@ -20,7 +20,7 @@
***/
int proc_cmdline(char **ret);
int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value));
int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value, void *data), void *data);
int get_proc_cmdline_key(const char *parameter, char **value);
int shall_restore_state(void);

View File

@ -307,7 +307,7 @@ static int set_machine_id(const char *m) {
return 0;
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
@ -1570,7 +1570,7 @@ int main(int argc, char *argv[]) {
}
if (arg_system) {
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
}

View File

@ -277,7 +277,7 @@ static crypto_device *get_crypto_device(const char *uuid) {
return d;
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
crypto_device *d;
_cleanup_free_ char *uuid = NULL, *uuid_value = NULL;
@ -478,7 +478,7 @@ int main(int argc, char *argv[]) {
if (!arg_disks)
goto cleanup;
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0) {
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");
r = EXIT_FAILURE;

View File

@ -33,7 +33,7 @@ static char **arg_mask = NULL;
static char **arg_wants = NULL;
static bool arg_debug_shell = false;
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
assert(key);
@ -178,7 +178,7 @@ int main(int argc, char *argv[]) {
goto finish;
}
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -94,7 +94,7 @@ static void start_target(const char *target, const char *mode) {
log_error("Failed to start unit: %s", bus_error_message(&error, r));
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
assert(key);
@ -293,7 +293,7 @@ int main(int argc, char *argv[]) {
umask(0022);
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -590,7 +590,7 @@ static int add_sysroot_usr_mount(void) {
"/proc/cmdline");
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
/* root=, usr=, usrfstype= and roofstype= may occur more than once, the last
@ -674,7 +674,7 @@ int main(int argc, char *argv[]) {
umask(0022);
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -907,7 +907,7 @@ fallback:
return 1;
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
assert(key);
@ -1018,7 +1018,7 @@ int main(int argc, char *argv[]) {
return EXIT_SUCCESS;
}
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -33,7 +33,7 @@
static const char *arg_dest = "/tmp";
static char *arg_resume_dev = NULL;
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
if (streq(key, "resume") && value) {
free(arg_resume_dev);
@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
if (!in_initrd())
return EXIT_SUCCESS;
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -59,7 +59,7 @@ static int add_modules(const char *p) {
return 0;
}
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
int r;
if (STR_IN_SET(key, "modules-load", "rd.modules-load") && value) {
@ -226,7 +226,7 @@ int main(int argc, char *argv[]) {
umask(0022);
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -32,7 +32,7 @@
static bool arg_skip = false;
static bool arg_force = false;
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
if (streq(key, "quotacheck.mode") && value) {
@ -88,7 +88,7 @@ int main(int argc, char *argv[]) {
umask(0022);
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "Failed to parse kernel command line, ignoring: %m");

View File

@ -25,15 +25,18 @@
#include "string-util.h"
#include "util.h"
static int parse_item(const char *key, const char *value) {
static int obj;
static int parse_item(const char *key, const char *value, void *data) {
assert_se(key);
assert_se(data == &obj);
log_info("kernel cmdline option <%s> = <%s>", key, strna(value));
return 0;
}
static void test_parse_proc_cmdline(void) {
assert_se(parse_proc_cmdline(parse_item) >= 0);
assert_se(parse_proc_cmdline(parse_item, &obj) >= 0);
}
static void test_runlevel_to_target(void) {

View File

@ -1362,7 +1362,7 @@ static int listen_fds(int *rctrl, int *rnetlink) {
* udev.exec-delay=<number of seconds> delay execution of every executed program
* udev.event-timeout=<number of seconds> seconds to wait before terminating an event
*/
static int parse_proc_cmdline_item(const char *key, const char *value) {
static int parse_proc_cmdline_item(const char *key, const char *value, void *data) {
const char *full_key = key;
int r;
@ -1665,7 +1665,7 @@ int main(int argc, char *argv[]) {
if (r <= 0)
goto exit;
r = parse_proc_cmdline(parse_proc_cmdline_item);
r = parse_proc_cmdline(parse_proc_cmdline_item, NULL);
if (r < 0)
log_warning_errno(r, "failed to parse kernel command line, ignoring: %m");