From: Gary Bisson Date: Wed, 18 Dec 2013 01:03:06 +0000 (-0800) Subject: mtd-utils: nanddump: write requested length only X-Git-Tag: v2.0.0-rc1~44 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=76c64d6ca9e9258b74ec13d13496eb7ca872a288;p=mtd-utils.git 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 --- 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;