Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/miscutils/nandwrite.c
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/miscutils/nandwrite.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_NANDWRITE(APPLET(nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP))12 //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, _BB_DIR_USR_SBIN, _BB_SUID_DROP, nanddump))13 14 //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o15 //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o16 17 11 //config:config NANDWRITE 18 12 //config: bool "nandwrite" 19 //config: default n20 //config: depends onPLATFORM_LINUX13 //config: default y 14 //config: select PLATFORM_LINUX 21 15 //config: help 22 16 //config: Write to the specified MTD device, with bad blocks awareness … … 24 18 //config:config NANDDUMP 25 19 //config: bool "nanddump" 26 //config: default n27 //config: depends onPLATFORM_LINUX20 //config: default y 21 //config: select PLATFORM_LINUX 28 22 //config: help 29 23 //config: Dump the content of raw NAND chip 24 25 //applet:IF_NANDWRITE(APPLET(nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP)) 26 //applet:IF_NANDWRITE(APPLET_ODDNAME(nanddump, nandwrite, BB_DIR_USR_SBIN, BB_SUID_DROP, nanddump)) 27 28 //kbuild:lib-$(CONFIG_NANDWRITE) += nandwrite.o 29 //kbuild:lib-$(CONFIG_NANDDUMP) += nandwrite.o 30 30 31 31 //usage:#define nandwrite_trivial_usage … … 33 33 //usage:#define nandwrite_full_usage "\n\n" 34 34 //usage: "Write to the specified MTD device\n" 35 //usage: "\nOptions:"36 35 //usage: "\n -p Pad to page size" 37 36 //usage: "\n -s ADDR Start address" … … 40 39 //usage: "[-o] [-b] [-s ADDR] [-f FILE] MTD_DEVICE" 41 40 //usage:#define nanddump_full_usage "\n\n" 42 //usage: "Dump the sepcified MTD device\n" 43 //usage: "\nOptions:" 44 //usage: "\n -o Omit oob data" 41 //usage: "Dump the specified MTD device\n" 42 //usage: "\n -o Dump oob data" 45 43 //usage: "\n -b Omit bad block from the dump" 46 44 //usage: "\n -s ADDR Start address" … … 132 130 } 133 131 134 fd = xopen(argv[0], O_RDWR);132 fd = xopen(argv[0], IS_NANDWRITE ? O_RDWR : O_RDONLY); 135 133 xioctl(fd, MEMGETINFO, &meminfo); 136 134 … … 165 163 if (tmp != blockstart) { 166 164 /* bad block(s), advance mtdoffset */ 167 if (IS_NANDDUMP & !(opts & OPT_b)) {165 if (IS_NANDDUMP && !(opts & OPT_b)) { 168 166 int bad_len = MIN(tmp, end_addr) - mtdoffset; 169 dump_bad(&meminfo, bad_len, !(opts & OPT_o));167 dump_bad(&meminfo, bad_len, opts & OPT_o); 170 168 } 171 169 mtdoffset = tmp; … … 185 183 if (IS_NANDWRITE) 186 184 printf("Writing at 0x%08x\n", mtdoffset); 187 else if (mtdoffset > blockstart ) {185 else if (mtdoffset > blockstart && !(opts & OPT_b)) { 188 186 int bad_len = MIN(mtdoffset, limit) - blockstart; 189 dump_bad(&meminfo, bad_len, !(opts & OPT_o));187 dump_bad(&meminfo, bad_len, opts & OPT_o); 190 188 } 191 189 if (mtdoffset >= limit) … … 213 211 xwrite(output_fd, filebuf, meminfo_writesize); 214 212 215 if (IS_NANDDUMP && !(opts & OPT_o)) {213 if (IS_NANDDUMP && (opts & OPT_o)) { 216 214 /* Dump OOB data */ 217 215 oob.start = mtdoffset;
Note:
See TracChangeset
for help on using the changeset viewer.