diff mbox

[2/2] nanddump: add --nobad to read bad blocks

Message ID 1284263427-31342-2-git-send-email-vapier@gentoo.org
State Accepted, archived
Commit 2c681d34611bf5b4a92efd51642ebd4723711679
Headers show

Commit Message

Mike Frysinger Sept. 12, 2010, 3:50 a.m. UTC
Sometimes dumping bad blocks is useful, like when the data 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>
---
 nanddump.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

Comments

Artem Bityutskiy Sept. 12, 2010, 8:11 a.m. UTC | #1
On Sat, 2010-09-11 at 23:50 -0400, Mike Frysinger wrote:
> Sometimes dumping bad blocks is useful, like when the data 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>
> ---
>  nanddump.c |   12 ++++++++++--
>  1 files changed, 10 insertions(+), 2 deletions(-)

Pushed, thanks.
Jon Povey Sept. 13, 2010, 5:50 a.m. UTC | #2
Mike Frysinger wrote:
> Sometimes dumping bad blocks is useful, like when the data 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.

> +"-N         --nobad              Read without bad block skipping\n"

This doesn't seem like a good name for the option to me. A useful option but an unintuitive name, "nobad" sounds like it is going to omit bad blocks, where actually it is going to include them.

"noskipbad" or "includebad" would seem to be better.

I see this got pushed already though..

--
Jon Povey
jon.povey@racelogic.co.uk

Racelogic is a limited company registered in England. Registered number 2743719 .
Registered Office Unit 10, Swan Business Centre, Osier Way, Buckingham, Bucks, MK18 1TB .

The information contained in this electronic mail transmission is intended by Racelogic Ltd for the use of the named individual or entity to which it is directed and may contain information that is confidential or privileged. If you have received this electronic mail transmission in error, please delete it from your system without copying or forwarding it, and notify the sender of the error by reply email so that the sender's address records can be corrected. The views expressed by the sender of this communication do not necessarily represent those of Racelogic Ltd. Please note that Racelogic reserves the right to monitor e-mail communications passing through its network
Wolfram Sang Sept. 13, 2010, 6:22 a.m. UTC | #3
On Mon, Sep 13, 2010 at 06:50:04AM +0100, Jon Povey wrote:
> Mike Frysinger wrote:
> > Sometimes dumping bad blocks is useful, like when the data 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.
> 
> > +"-N         --nobad              Read without bad block skipping\n"
> 
> This doesn't seem like a good name for the option to me. A useful option but
> an unintuitive name, "nobad" sounds like it is going to omit bad blocks,
> where actually it is going to include them.
> 
> "noskipbad" or "includebad" would seem to be better.

I agree. Is that still fixable despite being pushed already?
Artem Bityutskiy Sept. 13, 2010, 6:24 a.m. UTC | #4
On Mon, 2010-09-13 at 08:22 +0200, Wolfram Sang wrote:
> On Mon, Sep 13, 2010 at 06:50:04AM +0100, Jon Povey wrote:
> > Mike Frysinger wrote:
> > > Sometimes dumping bad blocks is useful, like when the data 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.
> > 
> > > +"-N         --nobad              Read without bad block skipping\n"
> > 
> > This doesn't seem like a good name for the option to me. A useful option but
> > an unintuitive name, "nobad" sounds like it is going to omit bad blocks,
> > where actually it is going to include them.
> > 
> > "noskipbad" or "includebad" would seem to be better.
> 
> I agree. Is that still fixable despite being pushed already?

Sure, send a patch please.
diff mbox

Patch

diff --git a/nanddump.c b/nanddump.c
index 70b78f0..8b3d4a1 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -50,6 +50,7 @@  static void display_help (void)
 "-f file    --file=file          Dump to file\n"
 "-l length  --length=length      Length\n"
 "-n         --noecc              Read without error correction\n"
+"-N         --nobad              Read without bad block skipping\n"
 "-o         --omitoob            Omit oob data\n"
 "-b         --omitbad            Omit bad blocks from the dump\n"
 "-p         --prettyprint        Print nice (hexdump)\n"
@@ -76,6 +77,7 @@  static void display_version (void)
 
 static bool		pretty_print = false;	// print nice
 static bool		noecc = false;		// don't error correct
+static bool		nobad = false;		// don't skip bad blocks
 static bool		omitoob = false;	// omit oob data
 static unsigned long	start_addr;		// start address
 static unsigned long	length;			// dump length
@@ -92,7 +94,7 @@  static void process_options (int argc, char * const argv[])
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "bs:f:l:opqnca";
+		static const char *short_options = "bs:f:l:opqnNca";
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
@@ -105,6 +107,7 @@  static void process_options (int argc, char * const argv[])
 			{"startaddress", required_argument, 0, 's'},
 			{"length", required_argument, 0, 'l'},
 			{"noecc", no_argument, 0, 'n'},
+			{"nobad", no_argument, 0, 'N'},
 			{"quiet", no_argument, 0, 'q'},
 			{0, 0, 0, 0},
 		};
@@ -158,6 +161,9 @@  static void process_options (int argc, char * const argv[])
 			case 'n':
 				noecc = true;
 				break;
+			case 'N':
+				nobad = true;
+				break;
 			case '?':
 				error++;
 				break;
@@ -390,7 +396,9 @@  int main(int argc, char * const argv[])
 	for (ofs = start_addr; ofs < end_addr ; ofs+=bs) {
 
 		// new eraseblock , check for bad block
-		if (blockstart != (ofs & (~meminfo.erasesize + 1))) {
+		if (nobad) {
+			badblock = 0;
+		} else if (blockstart != (ofs & (~meminfo.erasesize + 1))) {
 			blockstart = ofs & (~meminfo.erasesize + 1);
 			if ((badblock = ioctl(fd, MEMGETBADBLOCK, &blockstart)) < 0) {
 				perror("ioctl(MEMGETBADBLOCK)");