diff mbox

[v2] nandwrite: add --nobad to write bad blocks

Message ID 1285272255-6980-1-git-send-email-vapier@gentoo.org
State Accepted, archived
Commit 9781afc18f9e649f29ae835e2ce895a7149a337f
Headers show

Commit Message

Mike Frysinger Sept. 23, 2010, 8:04 p.m. UTC
Sometimes dumping bad blocks is useful, like when the block isn't actually
bad but the OOB layout isn't what the kernel is expecting or is otherwise
screwed up.  The --nobad option allows just that.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
v2
	- rename --nobad to --noskipbad

 nandwrite.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

Comments

Artem Bityutskiy Sept. 24, 2010, 8:50 a.m. UTC | #1
On Thu, 2010-09-23 at 16:04 -0400, Mike Frysinger wrote:
> Sometimes dumping bad blocks is useful, like when the block isn't actually
> bad but the OOB layout isn't what the kernel is expecting or is otherwise
> screwed up.  The --nobad option allows just that.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
> ---
> v2
> 	- rename --nobad to --noskipbad

Amended the comments and pushed, thanks.
Mike Frysinger Sept. 24, 2010, 12:33 p.m. UTC | #2
On Fri, Sep 24, 2010 at 04:50, Artem Bityutskiy wrote:
> On Thu, 2010-09-23 at 16:04 -0400, Mike Frysinger wrote:
>> Sometimes dumping bad blocks is useful, like when the block isn't actually
>> bad but the OOB layout isn't what the kernel is expecting or is otherwise
>> screwed up.  The --nobad option allows just that.
>>
>> v2
>>       - rename --nobad to --noskipbad
>
> Amended the comments and pushed, thanks.

oops ... thanks :)
-mike
diff mbox

Patch

diff --git a/nandwrite.c b/nandwrite.c
index 1b4ca3d..8fe8875 100644
--- a/nandwrite.c
+++ b/nandwrite.c
@@ -79,6 +79,7 @@  static void display_help (void)
 "                          device\n"
 "  -m, --markbad           Mark blocks bad if write fails\n"
 "  -n, --noecc             Write without ecc\n"
+"  -N, --noskipbad         Write without bad block skipping\n"
 "  -o, --oob               Image contains oob data\n"
 "  -r, --raw               Image contains the raw oob data dumped by nanddump\n"
 "  -s addr, --start=addr   Set start address (default is 0)\n"
@@ -118,6 +119,7 @@  static bool		forcejffs2 = false;
 static bool		forceyaffs = false;
 static bool		forcelegacy = false;
 static bool		noecc = false;
+static bool		noskipbad = false;
 static bool		pad = false;
 static int		blockalign = 1; /*default to using 16K block size */
 
@@ -127,7 +129,7 @@  static void process_options (int argc, char * const argv[])
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "ab:fjmnopqrs:y";
+		static const char *short_options = "ab:fjmnNopqrs:y";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
@@ -137,6 +139,7 @@  static void process_options (int argc, char * const argv[])
 			{"jffs2", no_argument, 0, 'j'},
 			{"markbad", no_argument, 0, 'm'},
 			{"noecc", no_argument, 0, 'n'},
+			{"noskipbad", no_argument, 0, 'N'},
 			{"oob", no_argument, 0, 'o'},
 			{"pad", no_argument, 0, 'p'},
 			{"quiet", no_argument, 0, 'q'},
@@ -181,6 +184,9 @@  static void process_options (int argc, char * const argv[])
 			case 'n':
 				noecc = true;
 				break;
+			case 'N':
+				noskipbad = true;
+				break;
 			case 'm':
 				markbad = true;
 				break;
@@ -487,6 +493,8 @@  int main(int argc, char * const argv[])
 						 blockstart / meminfo.erasesize, blockstart);
 
 			/* Check all the blocks in an erase block for bad blocks */
+			if (noskipbad)
+				continue;
 			do {
 				if ((ret = ioctl(fd, MEMGETBADBLOCK, &offs)) < 0) {
 					perror("ioctl(MEMGETBADBLOCK)");