2 * Copyright (C) 2013 Felix Fietkau <nbd@openwrt.org>
3 * Copyright (C) 2013 John Crispin <blogic@openwrt.org>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License version 2.1
7 * as published by the Free Software Foundation
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
15 #include <sys/reboot.h>
22 #include <libubox/uloop.h>
26 static struct uloop_process upgrade_proc;
27 unsigned int debug = 2;
29 static void upgrade_proc_cb(struct uloop_process *proc, int ret)
32 fprintf(stderr, "sysupgrade aborted with return code: %d\n", ret);
36 static void sysupgarde(char *folder)
38 char *args[] = { "/sbin/sysupgrade", "nand", NULL, NULL };
41 upgrade_proc.cb = upgrade_proc_cb;
42 upgrade_proc.pid = fork();
43 if (!upgrade_proc.pid) {
44 execvp(args[0], args);
45 fprintf(stderr, "Failed to fork sysupgrade\n");
48 if (upgrade_proc.pid <= 0) {
49 fprintf(stderr, "Failed to start sysupgarde\n");
54 int main(int argc, char **argv)
61 fprintf(stderr, "this tool needs to run as pid 1\n");
65 fprintf(stderr, "sysupgrade stage 2 failed, no folder specified\n");