iopsys-feed/mtd-utils-mod/patches/110-image_offset.patch
2015-06-15 21:57:39 +02:00

57 lines
1.8 KiB
Diff

--- a/nandwrite.c 2009-03-14 02:09:35.000000000 +0100
+++ b/nandwrite.c 2012-09-14 12:31:22.821247513 +0200
@@ -88,6 +88,7 @@
" -n, --noecc Write without ecc\n"
" -o, --oob Image contains oob data\n"
" -s addr, --start=addr Set start address (default is 0)\n"
+" -i addr, --ioffs=addr Set offset of the input file (default is 0)\n"
" -p, --pad Pad to page size\n"
" -b, --blockalign=1|2|4 Set multiple of eraseblocks to align to\n"
" -q, --quiet Don't display progress messages\n"
@@ -115,6 +116,7 @@
static const char *standard_input = "-";
static const char *mtd_device, *img;
static int mtdoffset = 0;
+static int imgoffset = 0;
static bool quiet = false;
static bool writeoob = false;
static bool autoplace = false;
@@ -132,7 +134,7 @@
for (;;) {
int option_index = 0;
- static const char *short_options = "ab:fjmnopqs:y";
+ static const char *short_options = "ab:fjmnopqsi:y";
static const struct option long_options[] = {
{"help", no_argument, 0, 0},
{"version", no_argument, 0, 0},
@@ -146,6 +148,7 @@
{"pad", no_argument, 0, 'p'},
{"quiet", no_argument, 0, 'q'},
{"start", required_argument, 0, 's'},
+ {"ioffs", required_argument, 0, 'i'},
{"yaffs", no_argument, 0, 'y'},
{0, 0, 0, 0},
};
@@ -197,6 +200,9 @@
case 's':
mtdoffset = strtol (optarg, NULL, 0);
break;
+ case 'i':
+ imgoffset = strtol (optarg, NULL, 0);
+ break;
case 'b':
blockalign = atoi (optarg);
break;
@@ -411,9 +417,10 @@
if (ifd == STDIN_FILENO) {
imglen = pagelen;
+ lseek (ifd, imgoffset, SEEK_SET);
} else {
imglen = lseek(ifd, 0, SEEK_END);
- lseek (ifd, 0, SEEK_SET);
+ lseek (ifd, imgoffset, SEEK_SET);
}
// Check, if file is page-aligned