From 059cb3858acd038ff2cef10a3a99119bf71a8fc6 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 6 Mar 2014 17:05:55 +0100 Subject: util: move more intellegince into parse_proc_cmdline() Already split variable assignments before invoking the callback. And drop "rd." settings if we are not in an initrd. --- src/fstab-generator/fstab-generator.c | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'src/fstab-generator/fstab-generator.c') diff --git a/src/fstab-generator/fstab-generator.c b/src/fstab-generator/fstab-generator.c index aac1a436ec..c50586b793 100644 --- a/src/fstab-generator/fstab-generator.c +++ b/src/fstab-generator/fstab-generator.c @@ -34,6 +34,7 @@ #include "mkdir.h" #include "fileio.h" #include "generator.h" +#include "strv.h" static const char *arg_dest = "/tmp"; static bool arg_fstab_enabled = true; @@ -461,32 +462,19 @@ static int parse_new_root_from_proc_cmdline(void) { return (r < 0) ? r : 0; } -static int parse_proc_cmdline_word(const char *word) { +static int parse_proc_cmdline_item(const char *key, const char *value) { int r; - if (startswith(word, "fstab=")) { + if (STR_IN_SET(key, "fstab", "rd.fstab") && value) { - r = parse_boolean(word + 6); + r = parse_boolean(value); if (r < 0) - log_warning("Failed to parse fstab switch %s. Ignoring.", word + 6); + log_warning("Failed to parse fstab switch %s. Ignoring.", value); else arg_fstab_enabled = r; - } else if (startswith(word, "rd.fstab=")) { - - if (in_initrd()) { - r = parse_boolean(word + 9); - if (r < 0) - log_warning("Failed to parse fstab switch %s. Ignoring.", word + 9); - else - arg_fstab_enabled = r; - } - - } else if (startswith(word, "fstab.") || - (in_initrd() && startswith(word, "rd.fstab."))) { - - log_warning("Unknown kernel switch %s. Ignoring.", word); - } + } else if (startswith(key, "fstab.") || startswith(key, "rd.fstab.")) + log_warning("Unknown kernel switch %s. Ignoring.", key); return 0; } @@ -508,7 +496,7 @@ int main(int argc, char *argv[]) { umask(0022); - if (parse_proc_cmdline(parse_proc_cmdline_word) < 0) + if (parse_proc_cmdline(parse_proc_cmdline_item) < 0) return EXIT_FAILURE; /* Always honour root= in the kernel command line if we are in an initrd */ -- cgit v1.2.3-54-g00ecf