chiark / gitweb /
initctl: check for kexec_loaded when reboot is requested through initctl
authorFrederic Crozat <fcrozat@suse.com>
Mon, 22 Aug 2011 12:58:50 +0000 (14:58 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 24 Aug 2011 00:19:30 +0000 (02:19 +0200)
src/initctl.c
src/systemctl.c
src/util.c
src/util.h

index f36f1cc..eaa717a 100644 (file)
@@ -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;
                 }
 
index 604400d..0a35d8e 100644 (file)
@@ -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 {
index 65d4b14..6033aa0 100644 (file)
@@ -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;
+}
index a6b700c..3e1f46d 100644 (file)
@@ -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