]> www.infradead.org Git - mtd-utils.git/commitdiff
mtd-utils: nanddump: write requested length only
authorGary Bisson <bisson.gary@gmail.com>
Wed, 18 Dec 2013 01:03:06 +0000 (17:03 -0800)
committerRichard Weinberger <richard@nod.at>
Thu, 25 Aug 2016 13:22:07 +0000 (15:22 +0200)
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>
nand-utils/nanddump.c

index 4ee7ed409d1eaacf6e5ba698a8adced05eed784a..300aca680781dad090d4679cbe232cb0e1b4b73b 100644 (file)
@@ -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;