- const char *argv[6];
- const char **p;
- char *s_initrd = NULL;
- char *s_args = NULL;
-
- p = argv;
- *p++ = pb_system_apps.kexec; /* 1 */
-
- if (l_initrd) {
- s_initrd = talloc_asprintf(NULL, "--initrd=%s", l_initrd);
- assert(s_initrd);
- *p++ = s_initrd; /* 2 */
- }
-
- if (args) {
- s_args = talloc_asprintf(NULL, "--append=%s", args);
- assert(s_args);
- *p++ = s_args; /* 3 */
- }
-
- /* First try by telling kexec to run shutdown */
-
- *(p + 0) = l_image;
- *(p + 1) = NULL;
-
- result = pb_run_cmd(argv);
-
- /* kexec will return zero on success */
- /* On error, force a kexec with the -f option */
-
- if (result) {
- *(p + 0) = "-f"; /* 4 */
- *(p + 1) = l_image; /* 5 */
- *(p + 2) = NULL; /* 6 */
-
- result = pb_run_cmd(argv);
- }
-
- if (result)
- pb_log("%s: failed: (%d)\n", __func__, result);
-
- talloc_free(s_initrd);
- talloc_free(s_args);