X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=discover%2Fboot.c;h=583d141ddc440ccaa45ae80288d664e65ec44828;hp=d9c606f9a5914acbf79104f1f90e79f337f2a2b3;hb=209b10507b8f95f9f549ecb81158034038334c36;hpb=823958fbbd17ab2c1b2a1779eb10351ca0a668c6 diff --git a/discover/boot.c b/discover/boot.c index d9c606f..583d141 100644 --- a/discover/boot.c +++ b/discover/boot.c @@ -77,7 +77,7 @@ static int kexec_load(struct boot_task *boot_task) *p++ = boot_task->local_image; /* 6 */ *p++ = NULL; /* 7 */ - result = pb_run_cmd(argv, 1, boot_task->dry_run); + result = process_run_simple_argv(boot_task, argv); if (result) pb_log("%s: failed: (%d)\n", __func__, result); @@ -91,31 +91,18 @@ static int kexec_load(struct boot_task *boot_task) * Must only be called after a successful call to kexec_load(). */ -static int kexec_reboot(bool dry_run) +static int kexec_reboot(struct boot_task *task) { - int result = 0; - const char *argv[4]; - const char **p; + int result; /* 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, dry_run); + result = process_run_simple(task, pb_system_apps.shutdown, "-r", + "now", NULL); /* 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, 0); + result = process_run_simple(task, pb_system_apps.kexec, + "-e", NULL); } if (result) @@ -123,13 +110,8 @@ static int kexec_reboot(bool dry_run) /* okay, kexec -e -f */ if (result) { - p = argv; - *p++ = pb_system_apps.kexec; /* 1 */ - *p++ = "-e"; /* 2 */ - *p++ = "-f"; /* 3 */ - *p++ = NULL; /* 4 */ - - result = pb_run_cmd(argv, 1, 0); + result = process_run_simple(task, pb_system_apps.kexec, + "-e", "-f", NULL); } if (result) @@ -308,7 +290,7 @@ int boot(void *ctx, struct discover_boot_option *opt, struct boot_command *cmd, } else if (opt && opt->boot_image) { image = opt->boot_image->url; } else { - pb_log("%s: no image specified", __func__); + pb_log("%s: no image specified\n", __func__); return -1; } @@ -389,13 +371,11 @@ no_load: if (clean_dtb) unlink(boot_task->local_dtb); - talloc_free(boot_task); - if (!result) { update_status(status_fn, status_arg, BOOT_STATUS_INFO, "performing kexec reboot"); - result = kexec_reboot(boot_task->dry_run); + result = kexec_reboot(boot_task); if (result) { update_status(status_fn, status_arg, BOOT_STATUS_ERROR, @@ -403,5 +383,7 @@ no_load: } } + talloc_free(boot_task); + return result; }