* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* $Id$
+ *
+ * code is based on linux-mtd example code
*/
#include <limits.h>
" erase erase all data on device\n"
" write <imagefile> write imagefile to device\n"
"Following options are available:\n"
- " -u unlock device before accessing it\n"
" -r reboot after successful command\n"
" -e <device> erase <device> before executing the command\n\n"
"Example: To write linux.trx to mtd4 labeled as linux and reboot afterwards\n"
erase[0] = NULL;
boot = 0;
- unlock = 0;
- printf("mtd: Modify data within a Memory Technology Device.\n"
- "Copyright (C) 2005 Waldemar Brodkorb <wbx@dass-it.de>,\n"
- " Felix Fietkau <nbd@vd-s.ath.cx>\n"
- "Documented by Mike Strates [dumpedcore] <mike@dilaudid.net>\n"
- "mtd has ABSOLUTELY NO WARRANTY and is licensed under the GNU GPL.\n\n");
-
- while ((ch = getopt(argc, argv, "ure:")) != -1)
+ while ((ch = getopt(argc, argv, "re:")) != -1)
switch (ch) {
- case 'u':
- unlock = 1;
- break;
case 'r':
boot = 1;
break;
i++;
}
- if (unlock)
- mtd_unlock(device);
+ mtd_unlock(device);
switch (cmd) {
case CMD_UNLOCK:
- mtd_unlock(device);
break;
case CMD_ERASE:
mtd_erase(device);
}
if (boot)
- reboot(0);
+ kill(1, 15); // send SIGTERM to init for reboot
return 0;
}