All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Bisson <bisson.gary@gmail.com>
To: linux-mtd@lists.infradead.org
Cc: Gary Bisson <bisson.gary@gmail.com>
Subject: [PATCH] mtd-utils: nanddump: write requested length only
Date: Tue, 17 Dec 2013 17:03:06 -0800	[thread overview]
Message-ID: <1387328586-24356-1-git-send-email-bisson.gary@gmail.com> (raw)

nanddump was always writing a whole page of data into the output
discarding the length actually requested. This patch allows to
write only the remaining length if oob is omitted. In case oob
is needed, it makes sense to copy the entire page.
---
 nanddump.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/nanddump.c b/nanddump.c
index 4ee7ed4..300aca6 100644
--- a/nanddump.c
+++ b/nanddump.c
@@ -445,8 +445,14 @@ int main(int argc, char * const argv[])
 						pretty_buf, PRETTY_BUF_LEN, true, canonical, ofs + i);
 				write(ofd, pretty_buf, strlen(pretty_buf));
 			}
-		} else
-			write(ofd, readbuf, bs);
+		} else {
+			/* Write requested length if oob is omitted */
+			size_t size_left = end_addr - ofs;
+			if (omitoob && (size_left < bs))
+				write(ofd, readbuf, size_left);
+			else
+				write(ofd, readbuf, bs);
+		}
 
 		if (omitoob)
 			continue;
-- 
1.8.5.1

                 reply	other threads:[~2013-12-18  1:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1387328586-24356-1-git-send-email-bisson.gary@gmail.com \
    --to=bisson.gary@gmail.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.