linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] nanddump: add --bb=METHOD option
@ 2011-06-13 23:31 Brian Norris
  2011-06-13 23:31 ` [PATCH 2/6] nanddump: remove --skipbad, leaving --bb=skipbad Brian Norris
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Brian Norris @ 2011-06-13 23:31 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

We have too many separate bad block handling methods:
 --omitbad
 --noskipbad
 --skipbad
On top of these, we have the default option: that bad blocks are
replaced with 0xFF.

These options will be unified under --bb=METHOD. The end goal will be
something like:

----------------------------------------------------------------------------------------------
Old option     New option     Comment
----------------------------------------------------------------------------------------------
<default>      --bb=padbad    dump flash data, substituting 0xFF for any bad blocks
--noskipbad    --bb=dumpbad   dump flash data, including any bad blocks
--skipbad      --bb=skipbad   dump good data, completely skipping any bad blocks (new default)
--omitbad      --bb=omitbad   dump flash data, substituting nothing for any bad blocks

The BB options are all mutually exclusive, so we check that we do not
have more than one BB option explicitly enabled on the command line.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 nanddump.c |   81 +++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 56 insertions(+), 25 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index c9d7e8b..c3771c5 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -47,6 +47,12 @@ static void display_help(void)
 "\n"
 "           --help               Display this help and exit\n"
 "           --version            Output version information and exit\n"
+"           --bb=METHOD          Choose a bad block handling method.\n"
+"                                METHOD can be:\n"
+"                                    padbad (default)\n"
+"                                    dumpbad\n"
+"                                    skipbad\n"
+"                                    omitbad\n"
 "-a         --forcebinary        Force printing of binary data to tty\n"
 "-b         --omitbad            Omit bad blocks from the dump\n"
 "-c         --canonicalprint     Print canonical Hex+ASCII dump\n"
@@ -60,11 +66,11 @@ static void display_help(void)
 "-q         --quiet              Don't display progress and status messages\n"
 "-s addr    --startaddress=addr  Start address\n"
 "\n"
-"Notes on --omitbad and --skipbad:\n"
+"Notes on --bb=omitbad and --bb=skipbad:\n"
 "  With either option, we stop dumping data when we encounter a bad block\n"
-"  and resume dumping at the next good block. However, with --omitbad, we\n"
+"  and resume dumping at the next good block. However, with `omitbad', we\n"
 "  count the bad block as part of the total dump length, whereas with\n"
-"  --skipbad, the bad block is 'skipped,' that is, not counted toward the\n"
+"  `skipbad', the bad block is skipped, that is, not counted toward the\n"
 "  total dump length.\n",
 	PROGRAM_NAME);
 	exit(EXIT_SUCCESS);
@@ -88,21 +94,26 @@ static void display_version(void)
 
 static bool			pretty_print = false;	// print nice
 static bool			noecc = false;		// don't error correct
-static bool			noskipbad = false;	// don't skip bad blocks
 static bool			omitoob = false;	// omit oob data
 static long long		start_addr;		// start address
 static long long		length;			// dump length
 static const char		*mtddev;		// mtd device name
 static const char		*dumpfile;		// dump file name
-static bool			omitbad = false;
 static bool			quiet = false;		// suppress diagnostic output
 static bool			canonical = false;	// print nice + ascii
 static bool			forcebinary = false;	// force printing binary to tty
-static bool			skipbad = false;	// skip over bad blocks
+
+static enum {
+	padbad,   // dump flash data, substituting 0xFF for any bad blocks
+	dumpbad,  // dump flash data, including any bad blocks
+	skipbad,  // dump good data, completely skipping any bad blocks
+	omitbad   // dump flash data, substituting nothing for any bad blocks
+} bb_method = padbad;
 
 static void process_options(int argc, char * const argv[])
 {
 	int error = 0;
+	bool bb_default = true;
 
 	for (;;) {
 		int option_index = 0;
@@ -110,6 +121,7 @@ static void process_options(int argc, char * const argv[])
 		static const struct option long_options[] = {
 			{"help", no_argument, 0, 0},
 			{"version", no_argument, 0, 0},
+			{"bb", required_argument, 0, 0},
 			{"forcebinary", no_argument, 0, 'a'},
 			{"canonicalprint", no_argument, 0, 'c'},
 			{"file", required_argument, 0, 'f'},
@@ -140,10 +152,30 @@ static void process_options(int argc, char * const argv[])
 					case 1:
 						display_version();
 						break;
+					case 2:
+						/* Handle --bb=METHOD */
+						if (!strcmp(optarg, "padbad"))
+							bb_method = padbad;
+						else if (!strcmp(optarg, "dumpbad"))
+							bb_method = dumpbad;
+						else if (!strcmp(optarg, "skipbad"))
+							bb_method = skipbad;
+						else if (!strcmp(optarg, "omitbad"))
+							bb_method = omitbad;
+						else
+							error++;
+						bb_default = false;
+						break;
 				}
 				break;
 			case 'b':
-				omitbad = true;
+				/* Check if bb_method was already set explicitly */
+				if (bb_default) {
+					bb_default = false;
+					bb_method = omitbad;
+				} else {
+					error++;
+				}
 				break;
 			case 's':
 				start_addr = simple_strtoll(optarg, &error);
@@ -175,10 +207,22 @@ static void process_options(int argc, char * const argv[])
 				noecc = true;
 				break;
 			case 'N':
-				noskipbad = true;
+				/* Check if bb_method was already set explicitly */
+				if (bb_default) {
+					bb_default = false;
+					bb_method = dumpbad;
+				} else {
+					error++;
+				}
 				break;
 			case 'k':
-				skipbad = true;
+				/* Check if bb_method was already set explicitly */
+				if (bb_default) {
+					bb_default = false;
+					bb_method = skipbad;
+				} else {
+					error++;
+				}
 				break;
 			case '?':
 				error++;
@@ -206,19 +250,6 @@ static void process_options(int argc, char * const argv[])
 		exit(EXIT_FAILURE);
 	}
 
-	if (noskipbad && skipbad) {
-		fprintf(stderr, "The noskipbad and skipbad options are "
-				"mutually-exclusive.\n"
-				"Choose one or the other.\n");
-		exit(EXIT_FAILURE);
-	}
-
-	if (omitbad && skipbad) {
-		fprintf(stderr, "The omitbad and skipbad options are mutually-"
-				"exclusive.\nChoose one or the other.\n");
-		exit(EXIT_FAILURE);
-	}
-
 	if ((argc - optind) != 1 || error)
 		display_help();
 
@@ -416,7 +447,7 @@ int main(int argc, char * const argv[])
 	/* Dump the flash contents */
 	for (ofs = start_addr; ofs < end_addr; ofs += bs) {
 		/* Check for bad block */
-		if (noskipbad) {
+		if (bb_method == dumpbad) {
 			badblock = 0;
 		} else if (blockstart != (ofs & (~mtd.eb_size + 1)) ||
 				firstblock) {
@@ -430,14 +461,14 @@ int main(int argc, char * const argv[])
 
 		if (badblock) {
 			/* skip bad block, increase end_addr */
-			if (skipbad) {
+			if (bb_method == skipbad) {
 				end_addr += mtd.eb_size;
 				ofs += mtd.eb_size - bs;
 				if (end_addr > mtd.size)
 					end_addr = mtd.size;
 				continue;
 			}
-			if (omitbad)
+			if (bb_method == omitbad)
 				continue;
 			memset(readbuf, 0xff, bs);
 		} else {
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/6] nanddump: remove --skipbad, leaving --bb=skipbad
  2011-06-13 23:31 [PATCH 1/6] nanddump: add --bb=METHOD option Brian Norris
@ 2011-06-13 23:31 ` Brian Norris
  2011-06-13 23:32 ` [PATCH 3/6] nanddump: deprecation messages for old BB options Brian Norris
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2011-06-13 23:31 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

We are moving to unify bad block handling methods under the --bb=METHOD
option. Since --skipbad has not been included in a mtd-utils release yet,
we can safely replace it without a deprecation and phase-out period.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 nanddump.c |   13 +------------
 1 files changed, 1 insertions(+), 12 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index c3771c5..a945081 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -57,7 +57,6 @@ static void display_help(void)
 "-b         --omitbad            Omit bad blocks from the dump\n"
 "-c         --canonicalprint     Print canonical Hex+ASCII dump\n"
 "-f file    --file=file          Dump to file\n"
-"-k         --skipbad            Skip over bad blocks (see below)\n"
 "-l length  --length=length      Length\n"
 "-n         --noecc              Read without error correction\n"
 "-N         --noskipbad          Read without bad block skipping\n"
@@ -117,7 +116,7 @@ static void process_options(int argc, char * const argv[])
 
 	for (;;) {
 		int option_index = 0;
-		static const char *short_options = "bs:f:l:opqnNcak";
+		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},
@@ -132,7 +131,6 @@ static void process_options(int argc, char * const argv[])
 			{"length", required_argument, 0, 'l'},
 			{"noecc", no_argument, 0, 'n'},
 			{"noskipbad", no_argument, 0, 'N'},
-			{"skipbad", no_argument, 0, 'k'},
 			{"quiet", no_argument, 0, 'q'},
 			{0, 0, 0, 0},
 		};
@@ -215,15 +213,6 @@ static void process_options(int argc, char * const argv[])
 					error++;
 				}
 				break;
-			case 'k':
-				/* Check if bb_method was already set explicitly */
-				if (bb_default) {
-					bb_default = false;
-					bb_method = skipbad;
-				} else {
-					error++;
-				}
-				break;
 			case '?':
 				error++;
 				break;
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/6] nanddump: deprecation messages for old BB options
  2011-06-13 23:31 [PATCH 1/6] nanddump: add --bb=METHOD option Brian Norris
  2011-06-13 23:31 ` [PATCH 2/6] nanddump: remove --skipbad, leaving --bb=skipbad Brian Norris
@ 2011-06-13 23:32 ` Brian Norris
  2011-06-13 23:32 ` [PATCH 4/6] nanddump: warn about changing default badblock method Brian Norris
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2011-06-13 23:32 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

--omitbad and --noskipbad will soon be replaced by --bb=omitbad and
--bb=dumpbad. Please plan to migrate to the new usage shortly.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 nanddump.c |   14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index a945081..4f28e33 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -54,17 +54,21 @@ static void display_help(void)
 "                                    skipbad\n"
 "                                    omitbad\n"
 "-a         --forcebinary        Force printing of binary data to tty\n"
-"-b         --omitbad            Omit bad blocks from the dump\n"
 "-c         --canonicalprint     Print canonical Hex+ASCII dump\n"
 "-f file    --file=file          Dump to file\n"
 "-l length  --length=length      Length\n"
 "-n         --noecc              Read without error correction\n"
-"-N         --noskipbad          Read without bad block skipping\n"
 "-o         --omitoob            Omit oob data\n"
 "-p         --prettyprint        Print nice (hexdump)\n"
 "-q         --quiet              Don't display progress and status messages\n"
 "-s addr    --startaddress=addr  Start address\n"
 "\n"
+"Deprecated options:\n"
+"The following options are being replaced by --bb=METHOD flags.\n"
+"Do not continue to use these options.\n"
+"-b         --omitbad            Omit bad blocks from the dump\n"
+"-N         --noskipbad          Read without bad block skipping\n"
+"\n"
 "Notes on --bb=omitbad and --bb=skipbad:\n"
 "  With either option, we stop dumping data when we encounter a bad block\n"
 "  and resume dumping at the next good block. However, with `omitbad', we\n"
@@ -171,6 +175,9 @@ static void process_options(int argc, char * const argv[])
 				if (bb_default) {
 					bb_default = false;
 					bb_method = omitbad;
+					fprintf(stderr, "Warning: --omitbad is being deprecated in favor of --bb=omitbad.\n"
+							"         --omitbad will not be available in future releases.\n"
+							"         Please update your usage accordingly.\n");
 				} else {
 					error++;
 				}
@@ -209,6 +216,9 @@ static void process_options(int argc, char * const argv[])
 				if (bb_default) {
 					bb_default = false;
 					bb_method = dumpbad;
+					fprintf(stderr, "Warning: --noskipbad is being deprecated in favor of --bb=dumpbad.\n"
+							"         --noskipbad will not be available in future releases.\n"
+							"         Please update your usage accordingly.\n");
 				} else {
 					error++;
 				}
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/6] nanddump: warn about changing default badblock method
  2011-06-13 23:31 [PATCH 1/6] nanddump: add --bb=METHOD option Brian Norris
  2011-06-13 23:31 ` [PATCH 2/6] nanddump: remove --skipbad, leaving --bb=skipbad Brian Norris
  2011-06-13 23:32 ` [PATCH 3/6] nanddump: deprecation messages for old BB options Brian Norris
@ 2011-06-13 23:32 ` Brian Norris
  2011-06-13 23:32 ` [PATCH 5/6] feature-removal-schedule: describe nanddump changes Brian Norris
  2011-06-13 23:32 ` [PATCH 6/6] nanddump: warn about future default --nooob Brian Norris
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2011-06-13 23:32 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

In an upcoming release, we will no longer default to --bb=padbad. Instead,
the default will be --bb=skipbad. This makes nanddump a better inverse
operation to nandwrite.

This patch prints warnings for users so that they get a chance to update
their scripts before the default changes officially.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 nanddump.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index 4f28e33..211f8ae 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -249,6 +249,11 @@ static void process_options(int argc, char * const argv[])
 		exit(EXIT_FAILURE);
 	}
 
+	if (bb_default)
+		fprintf(stderr, "Warning: you did not specify a default bad-block handling\n"
+				"  method. In future versions, the default will change to\n"
+				"  --bb=skipbad. Use \"nanddump --help\" for more information.\n");
+
 	if ((argc - optind) != 1 || error)
 		display_help();
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] feature-removal-schedule: describe nanddump changes
  2011-06-13 23:31 [PATCH 1/6] nanddump: add --bb=METHOD option Brian Norris
                   ` (2 preceding siblings ...)
  2011-06-13 23:32 ` [PATCH 4/6] nanddump: warn about changing default badblock method Brian Norris
@ 2011-06-13 23:32 ` Brian Norris
  2011-06-13 23:32 ` [PATCH 6/6] nanddump: warn about future default --nooob Brian Norris
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2011-06-13 23:32 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

Include a few notes about the edited options and new default options in
nanddump.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 feature-removal-schedule.txt |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/feature-removal-schedule.txt b/feature-removal-schedule.txt
index a5980f7..0f1f5c5 100644
--- a/feature-removal-schedule.txt
+++ b/feature-removal-schedule.txt
@@ -40,3 +40,28 @@ This is duplicating behavior with the mtdinfo utility.  Now the util
 warns when people use it, but it'll be removed in release 1.4.6.
 
 ---------------------------
+
+4. Rename --omitbad and --noskipbad options for nanddump, change default
+
+These and a few other bad block handling methods are getting disorganized. They
+will be replaced by a series of --bb=METHOD options (see 'nanddump --help').
+
+In addition, the previous default bad block behavior was to dump 0xFF in place
+of bad blocks. This was not a good "inverse operation" of nandwrite. Thus, the
+current default behavior has become the (new) option --bb=padbad, and in 1.4.6,
+the default will be --bb=skipbad.
+
+All of these changes will occur in 1.4.6. For now, there are appropriate
+deprecation warning messages and an alert telling about the soon-to-be-default
+options.
+
+Transition summary table:
+-----------------------------------------------------------------------------------------------------------
+ Old option     New option                 Comment
+-----------------------------------------------------------------------------------------------------------
+ <default>      --bb=padbad                dump flash data, substituting 0xFF for any bad blocks
+ --noskipbad    --bb=dumpbad               dump flash data, including any bad blocks
+ --skipbad      --bb=skipbad, <default>    dump good data, completely skipping any bad blocks (new default)
+ --omitbad      --bb=omitbad               dump flash data, substituting nothing for any bad blocks
+
+---------------------------
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] nanddump: warn about future default --nooob
  2011-06-13 23:31 [PATCH 1/6] nanddump: add --bb=METHOD option Brian Norris
                   ` (3 preceding siblings ...)
  2011-06-13 23:32 ` [PATCH 5/6] feature-removal-schedule: describe nanddump changes Brian Norris
@ 2011-06-13 23:32 ` Brian Norris
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2011-06-13 23:32 UTC (permalink / raw)
  To: Artem Bityutskiy; +Cc: Brian Norris, linux-mtd, Mike Frysinger

To work as a proper inverse to nandwrite, nanddump must not dump OOB data by
default. This patch prints a warning regarding the future change.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
 feature-removal-schedule.txt |    8 ++++++++
 nanddump.c                   |    3 +++
 2 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/feature-removal-schedule.txt b/feature-removal-schedule.txt
index 0f1f5c5..0bb5cb2 100644
--- a/feature-removal-schedule.txt
+++ b/feature-removal-schedule.txt
@@ -65,3 +65,11 @@ Transition summary table:
  --omitbad      --bb=omitbad               dump flash data, substituting nothing for any bad blocks
 
 ---------------------------
+
+5. nanddump will not dump OOB by default
+
+In 1.4.6, nanddump will not dump OOB by default. To dump OOB, you will have to
+explicitly use the option '-o' or '--oob'. For now, there is simply a warning
+every time you use nanddump.
+
+---------------------------
diff --git a/nanddump.c b/nanddump.c
index 211f8ae..9c2e326 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -355,6 +355,9 @@ int main(int argc, char * const argv[])
 
 	process_options(argc, argv);
 
+	fprintf(stderr, "Warning: in next release, nanddump will not dump OOB"
+			" by default.\n");
+
 	/* Initialize libmtd */
 	mtd_desc = libmtd_open();
 	if (!mtd_desc)
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-06-13 23:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-13 23:31 [PATCH 1/6] nanddump: add --bb=METHOD option Brian Norris
2011-06-13 23:31 ` [PATCH 2/6] nanddump: remove --skipbad, leaving --bb=skipbad Brian Norris
2011-06-13 23:32 ` [PATCH 3/6] nanddump: deprecation messages for old BB options Brian Norris
2011-06-13 23:32 ` [PATCH 4/6] nanddump: warn about changing default badblock method Brian Norris
2011-06-13 23:32 ` [PATCH 5/6] feature-removal-schedule: describe nanddump changes Brian Norris
2011-06-13 23:32 ` [PATCH 6/6] nanddump: warn about future default --nooob Brian Norris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).