diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-11-03 13:04:06 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-11-03 13:04:06 +0100 |
commit | 8ba576d0e698aebd153c4276aa024dcc5fc99525 (patch) | |
tree | b899e66a106f5dd8fac42ba835035f33b2d919e8 /src/basic/proc-cmdline.c | |
parent | 5dea1c1e7902ca07ca1ea7f1914031c6e3a27be5 (diff) | |
parent | 7dcc56715d150ff7e8b5459877879430cff790f7 (diff) |
Merge pull request #1744 from evverx/fix-debug-generator
debug-generator: respect kernel parameters for default unit setting
Diffstat (limited to 'src/basic/proc-cmdline.c')
-rw-r--r-- | src/basic/proc-cmdline.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/basic/proc-cmdline.c b/src/basic/proc-cmdline.c index 778c994501..4464573c5b 100644 --- a/src/basic/proc-cmdline.c +++ b/src/basic/proc-cmdline.c @@ -26,6 +26,7 @@ #include "parse-util.h" #include "proc-cmdline.h" #include "process-util.h" +#include "special.h" #include "string-util.h" #include "util.h" #include "virt.h" @@ -143,3 +144,31 @@ int shall_restore_state(void) { return parse_boolean(value); } + +static const char * const rlmap[] = { + "emergency", SPECIAL_EMERGENCY_TARGET, + "-b", SPECIAL_EMERGENCY_TARGET, + "rescue", SPECIAL_RESCUE_TARGET, + "single", SPECIAL_RESCUE_TARGET, + "-s", SPECIAL_RESCUE_TARGET, + "s", SPECIAL_RESCUE_TARGET, + "S", SPECIAL_RESCUE_TARGET, + "1", SPECIAL_RESCUE_TARGET, + "2", SPECIAL_MULTI_USER_TARGET, + "3", SPECIAL_MULTI_USER_TARGET, + "4", SPECIAL_MULTI_USER_TARGET, + "5", SPECIAL_GRAPHICAL_TARGET, +}; + +const char* runlevel_to_target(const char *word) { + size_t i; + + if (!word) + return NULL; + + for (i = 0; i < ELEMENTSOF(rlmap); i += 2) + if (streq(word, rlmap[i])) + return rlmap[i+1]; + + return NULL; +} |