diff options
author | Waldemar Brodkorb <wbx@openadk.org> | 2009-12-29 01:04:10 +0100 |
---|---|---|
committer | Waldemar Brodkorb <wbx@openadk.org> | 2009-12-29 01:04:10 +0100 |
commit | 08409051bea263523a0883b2fc3167d1da3612b4 (patch) | |
tree | d4aab582e33bd20ff4c14a71d33f008b0fb1e690 /package/mtd | |
parent | 00ba3e5ce046f7f8d140321e18985048dbfb54f6 (diff) |
add atm network script
order network scripts. Add atm example. enable reboot option
for mtd.
Diffstat (limited to 'package/mtd')
-rw-r--r-- | package/mtd/src/mtd.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c index 6812c5e31..1230688b1 100644 --- a/package/mtd/src/mtd.c +++ b/package/mtd/src/mtd.c @@ -43,6 +43,7 @@ #include <string.h> #include <mtd/mtd-user.h> +#include <linux/reboot.h> #define BUFSIZE (16 * 1024) #define MAX_ARGS 8 @@ -253,15 +254,16 @@ usage(void) " -q quiet mode (once: no [w] on writing,\n" " twice: no status messages)\n" " -e <device> erase <device> before executing the command\n\n" - "Example: To write linux.trx to mtd1 labeled as linux\n" - " mtd write linux.trx linux\n\n"); + " -r reboot after successful command\n" + "Example: To write linux.img to mtd partition labeled as linux\n" + " mtd write linux.img linux\n\n"); exit(1); } int main(int argc, char **argv) { - int ch, i, imagefd = -1, quiet, unlocked; + int ch, i, imagefd = -1, quiet, unlocked, boot; char *erase[MAX_ARGS], *device; const char *imagefile = NULL; enum { @@ -271,6 +273,7 @@ main(int argc, char **argv) } cmd; erase[0] = NULL; + boot = 0; buflen = 0; quiet = 0; @@ -282,6 +285,9 @@ main(int argc, char **argv) case 'q': quiet++; break; + case 'r': + boot = 1; + break; case 'e': i = 0; while ((erase[i] != NULL) && ((i + 1) < MAX_ARGS)) @@ -373,7 +379,13 @@ main(int argc, char **argv) fprintf(stderr, "\n"); break; } - + sync(); + if (boot) { + fprintf(stderr, "\nRebooting ... "); + fflush(stdout); + fflush(stderr); + syscall(SYS_reboot,LINUX_REBOOT_MAGIC1,LINUX_REBOOT_MAGIC2,LINUX_REBOOT_CMD_RESTART,NULL); + } return 0; } |