#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
+#include <sys/ioctl.h>
+#include <sys/syscall.h>
#include <fcntl.h>
#include <errno.h>
#include <error.h>
#include <time.h>
+#include <string.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <sys/stat.h>
#include <sys/reboot.h>
-#include <string.h>
+#include <linux/reboot.h>
#include "mtd.h"
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);
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;
}