summaryrefslogtreecommitdiffstats
path: root/src/basic/proc-cmdline.c
diff options
context:
space:
mode:
authorIvan Shapovalov <intelfx@intelfx.name>2016-06-13 16:28:42 +0200
committerLennart Poettering <lennart@poettering.net>2016-06-13 16:28:42 +0200
commitdcd61450026c281c916f12c2affa220e0994ba19 (patch)
treec860dab75fc7750b38c4752c87dfd19f82a48b47 /src/basic/proc-cmdline.c
parentMerge pull request #3384 from keszybz/localed-keymap (diff)
downloadsystemd-dcd61450026c281c916f12c2affa220e0994ba19.tar.xz
systemd-dcd61450026c281c916f12c2affa220e0994ba19.zip
core: parse `rd.rescue` and `rd.emergency` as initrd-specific shorthands (#3488)
Typing `rd.rescue` is easier than `rd.systemd.unit=rescue.target`.
Diffstat (limited to 'src/basic/proc-cmdline.c')
-rw-r--r--src/basic/proc-cmdline.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c
index 3505fa9c9a..0430beadaa 100644
--- a/src/basic/proc-cmdline.c
+++ b/src/basic/proc-cmdline.c
@@ -160,17 +160,29 @@ static const char * const rlmap[] = {
"3", SPECIAL_MULTI_USER_TARGET,
"4", SPECIAL_MULTI_USER_TARGET,
"5", SPECIAL_GRAPHICAL_TARGET,
+ NULL
+};
+
+static const char * const rlmap_initrd[] = {
+ "emergency", SPECIAL_EMERGENCY_TARGET,
+ "rescue", SPECIAL_RESCUE_TARGET,
+ NULL
};
const char* runlevel_to_target(const char *word) {
size_t i;
+ const char * const *rlmap_ptr = in_initrd() ? rlmap_initrd
+ : rlmap;
if (!word)
return NULL;
- for (i = 0; i < ELEMENTSOF(rlmap); i += 2)
- if (streq(word, rlmap[i]))
- return rlmap[i+1];
+ if (in_initrd() && (word = startswith(word, "rd.")) == NULL)
+ return NULL;
+
+ for (i = 0; rlmap_ptr[i] != NULL; i += 2)
+ if (streq(word, rlmap_ptr[i]))
+ return rlmap_ptr[i+1];
return NULL;
}