X-Git-Url: http://git.rohieb.name/openwrt.git/blobdiff_plain/91244ebf6b83c3e461b987b2f69f8dc4a3df0078..778f5a83b25b88a46e8da75206bf935a703aaa50:/package/mtd/src/mtd.c diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c index 80d09abd2..0a968409a 100644 --- a/package/mtd/src/mtd.c +++ b/package/mtd/src/mtd.c @@ -28,17 +28,20 @@ #include #include #include +#include +#include #include #include #include #include +#include #include #include #include #include #include #include -#include +#include #include "mtd.h" @@ -194,13 +197,18 @@ mtd_open(const char *mtd, int flags) FILE *fp; char dev[PATH_MAX]; int i; + int ret; if ((fp = fopen("/proc/mtd", "r"))) { while (fgets(dev, sizeof(dev), fp)) { if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) { snprintf(dev, sizeof(dev), "/dev/mtd/%d", i); + if ((ret=open(dev, flags))<0) { + snprintf(dev, sizeof(dev), "/dev/mtd%d", i); + ret=open(dev, flags); + } fclose(fp); - return open(dev, flags); + return ret; } } fclose(fp); @@ -458,8 +466,9 @@ int main (int argc, char **argv) sync(); - if (boot) - kill(1, 15); // send SIGTERM to init for reboot - + if (boot) { + fflush(stdout); + syscall(SYS_reboot,LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,LINUX_REBOOT_CMD_RESTART,NULL); + } return 0; }