aboutsummaryrefslogtreecommitdiff
path: root/nand-utils/nanddump.c
diff options
context:
space:
mode:
authorGary Bisson <bisson.gary@gmail.com>2013-12-17 17:03:06 -0800
committerRichard Weinberger <richard@nod.at>2016-08-25 15:22:07 +0200
commit76c64d6ca9e9258b74ec13d13496eb7ca872a288 (patch)
tree994ff8ab700aff0b8a36c4f1adb2221945070417 /nand-utils/nanddump.c
parente4c8885bddac201ba0ef88560d6444f39e1ff870 (diff)
mtd-utils: nanddump: write requested length only
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. Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'nand-utils/nanddump.c')
-rw-r--r--nand-utils/nanddump.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c
index 4ee7ed4..300aca6 100644
--- a/nand-utils/nanddump.c
+++ b/nand-utils/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;