summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2021-05-01 20:39:44 +0200
committerPali Rohár <pali.rohar@gmail.com>2021-05-01 20:39:44 +0200
commitf144067634445ee0842c4211367cf2ef8d662f71 (patch)
tree99f13f622a2018dad5ae1081d61e9d6644bce31f
parentbbf438e1a87a98311044cb83ccedecac80d81a97 (diff)
download0xFFFF-f144067634445ee0842c4211367cf2ef8d662f71.tar.bz2
local: Respect -s (simulate) flag for dump -e operation
-rw-r--r--src/local.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/src/local.c b/src/local.c
index e0eb999..732f4fe 100644
--- a/src/local.c
+++ b/src/local.c
@@ -228,7 +228,10 @@ static int local_nanddump(const char * file, int mtd, int offset, int length) {
snprintf(command, size+1, "nanddump --omitoob -s %d -l %d -f %s /dev/mtd%d", offset, length, file, mtd);
- ret = system(command);
+ if ( ! simulate )
+ ret = system(command);
+ else
+ ret = 0;
free(command);
@@ -452,19 +455,25 @@ int local_dump_image(enum image_type image, const char * file) {
ret = local_nanddump(file, nand_device[device].args[image].mtd, nand_device[device].args[image].offset, header);
if ( ret != 0 ) {
- unlink(file);
+ if ( ! simulate )
+ unlink(file);
ret = -1;
goto clean;
}
- fd = open(file, O_RDONLY);
- if ( fd >= 0 ) {
- if ( read(fd, buf, 20) == 20 && memcmp(buf, "NOLO!img\x02\x00\x00\x00\x00\x00\x00\x00", 16) == 0 )
- nlen = (buf[16] << 0) | (buf[17] << 8) | (buf[18] << 16) | (buf[19] << 24);
- close(fd);
+ if ( ! simulate ) {
+
+ fd = open(file, O_RDONLY);
+ if ( fd >= 0 ) {
+ if ( read(fd, buf, 20) == 20 && memcmp(buf, "NOLO!img\x02\x00\x00\x00\x00\x00\x00\x00", 16) == 0 )
+ nlen = (buf[16] << 0) | (buf[17] << 8) | (buf[18] << 16) | (buf[19] << 24);
+ close(fd);
+ }
+
+ unlink(file);
+
}
- unlink(file);
}
ret = local_nanddump(file, nand_device[device].args[image].mtd, nand_device[device].args[image].offset + header, nand_device[device].args[image].length - header);
@@ -476,6 +485,9 @@ int local_dump_image(enum image_type image, const char * file) {
goto clean;
}
+ if ( simulate )
+ goto clean;
+
fd = open(file, O_RDWR);
if ( fd < 0 )
goto clean;