chiark / gitweb /
initctl: check for kexec_loaded when reboot is requested through initctl
[elogind.git] / src / util.c
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;
+}