Signed-off-by: John Crispin <blogic@openwrt.org>
SVN-Revision: 43503
static int
mtd_dump(const char *mtd, int size)
{
static int
mtd_dump(const char *mtd, int size)
{
+ int ret = 0, offset = 0;
if (quiet < 2)
fprintf(stderr, "Dumping %s ...\n", mtd);
if (quiet < 2)
fprintf(stderr, "Dumping %s ...\n", mtd);
+ if (!size)
+ size = mtdsize;
+
+ buf = malloc(erasesize);
+ if (!buf)
+ return -1;
+
- char buf[256];
- int len = (size > sizeof(buf)) ? (sizeof(buf)) : (size);
+ int len = (size > erasesize) ? (erasesize) : (size);
int rlen = read(fd, buf, len);
if (rlen < 0) {
int rlen = read(fd, buf, len);
if (rlen < 0) {
+ if (!rlen || rlen != len)
+ if (mtd_block_is_bad(fd, offset)) {
+ fprintf(stderr, "skipping bad block at 0x%08x\n", offset);
+ } else {
+ size -= rlen;
+ write(1, buf, rlen);
+ }
+ offset += rlen;