public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: "Brian Norris" <computersforpeace@gmail.com>
To: "Artem Bityutskiy" <dedekind1@gmail.com>
Cc: linux-mtd@lists.infradead.org,
	Brian Norris <computersforpeace@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>
Subject: [RFC] nanddump: skip bad blocks, print full length with --omitbad
Date: Thu, 2 Jun 2011 11:15:11 -0700	[thread overview]
Message-ID: <1307038511-5968-1-git-send-email-computersforpeace@gmail.com> (raw)

I'm not sure the original intended use of nanddump's '--omitbad' option,
but as described below, it doesn't seem to make the most sense to me.
I'm curiouse whether this change should be implemented as yet another
new nanddump option (perhaps a '--skipbad' vs. '--omitbad'? this starts
getting confusing) or if we can simply modify the old behavior of
'--omitbad'.

Brian

----

If, for example, the following is executed on a device with a bad block
at block 0, we get an empty file:
    $ nanddump --length=131072 --omitbad --file=/tmp/foo /dev/mtd0

This does not make intuitive sense. Instead, nanddump should skip the
bad block and continue to dump good data from the next good block.

This patch adds an informative warning to let the user know that a bad
block was skipped to aid with those who may be used to the old method,
where we omit the bad block and simply dump nothing in its place.

---
 nanddump.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index 214fb12..e19e16a 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -403,8 +403,15 @@ int main(int argc, char * const argv[])
 		}
 
 		if (badblock) {
-			if (omitbad)
+			if (omitbad) {
+				/* skip bad block, increase end_addr */
+				fprintf(stderr, "Skipping bad block at 0x%08llx\n", ofs);
+				end_addr += mtd.eb_size;
+				ofs += mtd.eb_size - bs;
+				if (end_addr > mtd.size)
+					end_addr = mtd.size;
 				continue;
+			}
 			memset(readbuf, 0xff, bs);
 		} else {
 			/* Read page data and exit on failure */
-- 
1.7.0.4

             reply	other threads:[~2011-06-02 18:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-02 18:15 Brian Norris [this message]
2011-06-02 18:51 ` [RFC] nanddump: skip bad blocks, print full length with --omitbad Mike Frysinger
2011-06-02 22:40   ` Brian Norris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1307038511-5968-1-git-send-email-computersforpeace@gmail.com \
    --to=computersforpeace@gmail.com \
    --cc=dedekind1@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-mtd@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox