summaryrefslogtreecommitdiff
path: root/src/fstab-generator
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-06 17:05:55 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-06 18:48:22 +0100
commit059cb3858acd038ff2cef10a3a99119bf71a8fc6 (patch)
tree065a3a0c911856a6a02ab8f128890970b75bcb95 /src/fstab-generator
parent27d14fb331ba8144f99f4da2d13f15cf5c8b8a9f (diff)
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.
Diffstat (limited to 'src/fstab-generator')
-rw-r--r--src/fstab-generator/fstab-generator.c28
1 files changed, 8 insertions, 20 deletions
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 */