diff options
author | Alexander Shiyan <shc_work@mail.ru> | 2013-03-15 00:42:39 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-03-15 00:42:39 +0100 |
commit | 45dc96c8a6dce3aeea983f6c32572d4cee646b5d (patch) | |
tree | 1668e0af68ba823d14c2a95d42580396b7ef1bbe | |
parent | 0d61dcd6411129afa6b880653de0a1c4356974cc (diff) | |
download | busybox-w32-45dc96c8a6dce3aeea983f6c32572d4cee646b5d.tar.gz busybox-w32-45dc96c8a6dce3aeea983f6c32572d4cee646b5d.tar.bz2 busybox-w32-45dc96c8a6dce3aeea983f6c32572d4cee646b5d.zip |
flash_eraseall: implement -N
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | miscutils/flash_eraseall.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c index 0598371d5..bf9b739a1 100644 --- a/miscutils/flash_eraseall.c +++ b/miscutils/flash_eraseall.c | |||
@@ -11,10 +11,11 @@ | |||
11 | */ | 11 | */ |
12 | 12 | ||
13 | //usage:#define flash_eraseall_trivial_usage | 13 | //usage:#define flash_eraseall_trivial_usage |
14 | //usage: "[-jq] MTD_DEVICE" | 14 | //usage: "[-jNq] MTD_DEVICE" |
15 | //usage:#define flash_eraseall_full_usage "\n\n" | 15 | //usage:#define flash_eraseall_full_usage "\n\n" |
16 | //usage: "Erase an MTD device\n" | 16 | //usage: "Erase an MTD device\n" |
17 | //usage: "\n -j Format the device for jffs2" | 17 | //usage: "\n -j Format the device for jffs2" |
18 | //usage: "\n -N Don't skip bad blocks" | ||
18 | //usage: "\n -q Don't display progress messages" | 19 | //usage: "\n -q Don't display progress messages" |
19 | 20 | ||
20 | #include "libbb.h" | 21 | #include "libbb.h" |
@@ -22,9 +23,9 @@ | |||
22 | #include <linux/jffs2.h> | 23 | #include <linux/jffs2.h> |
23 | 24 | ||
24 | #define OPTION_J (1 << 0) | 25 | #define OPTION_J (1 << 0) |
25 | #define OPTION_Q (1 << 1) | 26 | #define OPTION_N (1 << 1) |
26 | #define IS_NAND (1 << 2) | 27 | #define OPTION_Q (1 << 2) |
27 | #define BBTEST (1 << 3) | 28 | #define IS_NAND (1 << 3) |
28 | 29 | ||
29 | /* mtd/jffs2-user.h used to have this atrocity: | 30 | /* mtd/jffs2-user.h used to have this atrocity: |
30 | extern int target_endian; | 31 | extern int target_endian; |
@@ -71,7 +72,7 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv) | |||
71 | char *mtd_name; | 72 | char *mtd_name; |
72 | 73 | ||
73 | opt_complementary = "=1"; | 74 | opt_complementary = "=1"; |
74 | flags = BBTEST | getopt32(argv, "jq"); | 75 | flags = getopt32(argv, "jNq"); |
75 | 76 | ||
76 | mtd_name = argv[optind]; | 77 | mtd_name = argv[optind]; |
77 | fd = xopen(mtd_name, O_RDWR); | 78 | fd = xopen(mtd_name, O_RDWR); |
@@ -139,7 +140,7 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv) | |||
139 | 140 | ||
140 | for (erase.start = 0; erase.start < meminfo.size; | 141 | for (erase.start = 0; erase.start < meminfo.size; |
141 | erase.start += meminfo.erasesize) { | 142 | erase.start += meminfo.erasesize) { |
142 | if (flags & BBTEST) { | 143 | if (!(flags & OPTION_N)) { |
143 | int ret; | 144 | int ret; |
144 | loff_t offset = erase.start; | 145 | loff_t offset = erase.start; |
145 | 146 | ||
@@ -154,7 +155,7 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv) | |||
154 | * types e.g. NOR | 155 | * types e.g. NOR |
155 | */ | 156 | */ |
156 | if (errno == EOPNOTSUPP) { | 157 | if (errno == EOPNOTSUPP) { |
157 | flags &= ~BBTEST; | 158 | flags |= OPTION_N; |
158 | if (flags & IS_NAND) | 159 | if (flags & IS_NAND) |
159 | bb_error_msg_and_die("bad block check not available"); | 160 | bb_error_msg_and_die("bad block check not available"); |
160 | } else { | 161 | } else { |