34 lines
859 B
Diff
34 lines
859 B
Diff
--- kexec-tools-1.101/kexec/kexec.c.orig1 2006-10-13 14:01:39.000000000 -0400
|
|
+++ kexec-tools-1.101/kexec/kexec.c 2006-10-13 14:10:28.000000000 -0400
|
|
@@ -698,6 +698,19 @@ void usage(void)
|
|
printf("\n");
|
|
}
|
|
|
|
+static int kexec_loaded(void)
|
|
+{
|
|
+ int ret;
|
|
+ FILE *fp;
|
|
+
|
|
+ fp = fopen("/sys/kernel/kexec_loaded", "r");
|
|
+ if (fp == NULL)
|
|
+ return -1;
|
|
+ fscanf(fp, "%d", &ret);
|
|
+ fclose(fp);
|
|
+ return ret;
|
|
+}
|
|
+
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int do_load = 1;
|
|
@@ -801,6 +814,10 @@ int main(int argc, char *argv[])
|
|
if (do_load && (result == 0)) {
|
|
result = my_load(type, fileind, argc, argv, kexec_flags);
|
|
}
|
|
+ /* Don't shutdown unless there is something to reboot to! */
|
|
+ if ((result == 0) && (do_shutdown || do_exec) && !kexec_loaded()) {
|
|
+ die("Nothing has been loaded!\n");
|
|
+ }
|
|
if ((result == 0) && do_shutdown) {
|
|
result = my_shutdown();
|
|
}
|