-/**
- * kexec_reboot - Helper to boot the new kernel.
- *
- * Must only be called after a successful call to kexec_load().
- */
-
-static int kexec_reboot(void)
-{
- int result;
- const char *argv[4];
- const char **p;
-
- /* First try running shutdown. Init scripts should run 'exec -e' */
-
- p = argv;
- *p++ = pb_system_apps.shutdown; /* 1 */
- *p++ = "-r"; /* 2 */
- *p++ = "now"; /* 3 */
- *p++ = NULL; /* 4 */
-
- result = pb_run_cmd(argv, 1);
-
- /* On error, force a kexec with the -e option */
-
- if (result) {
- p = argv;
- *p++ = pb_system_apps.kexec; /* 1 */
- *p++ = "-e"; /* 2 */
- *p++ = NULL; /* 3 */
-
- result = pb_run_cmd(argv, 1);
- }
-
- if (result)
- pb_log("%s: failed: (%d)\n", __func__, result);
-
- return result;
-}
-
-/**
- * pb_run_kexec - Run kexec with the supplied boot options.
- */
-
-int pb_run_kexec(const struct pb_kexec_data *kd)
-{
- int result;
- char *l_image = NULL;
- char *l_initrd = NULL;
- unsigned int clean_image = 0;
- unsigned int clean_initrd = 0;
-
- pb_log("%s: image: '%s'\n", __func__, kd->image);
- pb_log("%s: initrd: '%s'\n", __func__, kd->initrd);
- pb_log("%s: args: '%s'\n", __func__, kd->args);
-
- result = -1;
-
- if (kd->image) {
- l_image = pb_load_file(NULL, kd->image, &clean_image);
- if (!l_image)
- goto no_load;
- }
-
- if (kd->initrd) {
- l_initrd = pb_load_file(NULL, kd->initrd, &clean_initrd);
- if (!l_initrd)
- goto no_load;
- }
-
- if (!l_image && !l_initrd)
- goto no_load;
-
- result = kexec_load(l_image, l_initrd, kd->args);
-
-no_load:
- if (clean_image)
- unlink(l_image);
- if (clean_initrd)
- unlink(l_initrd);