Author: blogic
Date: 2014-12-03 21:22:32 +0100 (Wed, 03 Dec 2014)
New Revision: 43512

Modified:
   trunk/package/system/mtd/src/mtd.c
Log:
mtd: make the dump commnd honour the -o option

Signed-off-by: John Crispin <[email protected]>

Modified: trunk/package/system/mtd/src/mtd.c
===================================================================
--- trunk/package/system/mtd/src/mtd.c  2014-12-03 18:17:17 UTC (rev 43511)
+++ trunk/package/system/mtd/src/mtd.c  2014-12-03 20:22:32 UTC (rev 43512)
@@ -274,7 +274,7 @@
 }
 
 static int
-mtd_dump(const char *mtd, int size)
+mtd_dump(const char *mtd, int part_offset, int size)
 {
        int ret = 0, offset = 0;
        int fd;
@@ -292,6 +292,9 @@
        if (!size)
                size = mtdsize;
 
+       if (part_offset)
+               lseek(fd, part_offset, SEEK_SET);
+
        buf = malloc(erasesize);
        if (!buf)
                return -1;
@@ -769,10 +772,6 @@
                                }
                                break;
                        case 'o':
-                               if (!mtd_fixtrx) {
-                                       fprintf(stderr, "-o: is not available 
on this platform\n");
-                                       usage();
-                               }
                                errno = 0;
                                offset = strtoul(optarg, 0, 0);
                                if (errno) {
@@ -872,7 +871,7 @@
                        mtd_verify(device, imagefile);
                        break;
                case CMD_DUMP:
-                       mtd_dump(device, dump_len);
+                       mtd_dump(device, offset, dump_len);
                        break;
                case CMD_ERASE:
                        if (!unlocked)
_______________________________________________
openwrt-commits mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-commits

Reply via email to