diff options
author | Frederic Crozat <fcrozat@suse.com> | 2011-08-22 14:58:50 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2011-08-24 02:19:30 +0200 |
commit | 65457142f12ecc4bb39fad51b73b9d3e6eac4af5 (patch) | |
tree | 295b56a9697bf28c50124702e66b4ea1a9cc4311 | |
parent | 240fc26e03e93641523315222fea4cfbf71c0ef9 (diff) |
initctl: check for kexec_loaded when reboot is requested through initctl
-rw-r--r-- | src/initctl.c | 2 | ||||
-rw-r--r-- | src/systemctl.c | 12 | ||||
-rw-r--r-- | src/util.c | 12 | ||||
-rw-r--r-- | src/util.h | 2 |
4 files changed, 16 insertions, 12 deletions
diff --git a/src/initctl.c b/src/initctl.c index f36f1cc704..eaa717ad91 100644 --- a/src/initctl.c +++ b/src/initctl.c @@ -93,6 +93,8 @@ static const char *translate_runlevel(int runlevel, bool *isolate) { for (i = 0; i < ELEMENTSOF(table); i++) if (table[i].runlevel == runlevel) { *isolate = table[i].isolate; + if (runlevel == '6' && kexec_loaded()) + return SPECIAL_KEXEC_TARGET; return table[i].special; } diff --git a/src/systemctl.c b/src/systemctl.c index 604400d8fb..0a35d8e021 100644 --- a/src/systemctl.c +++ b/src/systemctl.c @@ -4427,18 +4427,6 @@ static int parse_time_spec(const char *t, usec_t *_u) { return 0; } -static bool kexec_loaded(void) { - bool loaded = false; - char *s; - - if (read_one_line_file("/sys/kernel/kexec_loaded", &s) >= 0) { - if (s[0] == '1') - loaded = true; - free(s); - } - return loaded; -} - static int shutdown_parse_argv(int argc, char *argv[]) { enum { diff --git a/src/util.c b/src/util.c index 65d4b143dc..6033aa05b2 100644 --- a/src/util.c +++ b/src/util.c @@ -5852,3 +5852,15 @@ static const char *const signal_table[] = { }; DEFINE_STRING_TABLE_LOOKUP(signal, int); + +bool kexec_loaded(void) { + bool loaded = false; + char *s; + + if (read_one_line_file("/sys/kernel/kexec_loaded", &s) >= 0) { + if (s[0] == '1') + loaded = true; + free(s); + } + return loaded; +} diff --git a/src/util.h b/src/util.h index a6b700c82e..3e1f46d826 100644 --- a/src/util.h +++ b/src/util.h @@ -504,4 +504,6 @@ int signal_from_string_try_harder(const char *s); extern int saved_argc; extern char **saved_argv; +bool kexec_loaded(void); + #endif |