aboutsummaryrefslogtreecommitdiffstats
path: root/tools/padjffs2/src/padjffs2.c
diff options
context:
space:
mode:
authorGabor Juhos <juhosg@openwrt.org>2013-09-25 20:03:19 +0000
committerGabor Juhos <juhosg@openwrt.org>2013-09-25 20:03:19 +0000
commit07b5a8ccf4eb079322bb8a666983e556fb826a3c (patch)
tree3b8154df230163178bb79a06977fa6d9f1533bf0 /tools/padjffs2/src/padjffs2.c
parent2a58f6b40bfd53ba9589f08eebb7b2f94bdab745 (diff)
downloadupstream-07b5a8ccf4eb079322bb8a666983e556fb826a3c.tar.gz
upstream-07b5a8ccf4eb079322bb8a666983e556fb826a3c.tar.bz2
upstream-07b5a8ccf4eb079322bb8a666983e556fb826a3c.zip
tools/padjffs2: allow to specify extra offset
This will be useful for firmware images which are using a custom header. Signed-off-by: Gabor Juhos <juhosg@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@38195 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'tools/padjffs2/src/padjffs2.c')
-rw-r--r--tools/padjffs2/src/padjffs2.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/padjffs2/src/padjffs2.c b/tools/padjffs2/src/padjffs2.c
index 58d99140d9..aa932efa6f 100644
--- a/tools/padjffs2/src/padjffs2.c
+++ b/tools/padjffs2/src/padjffs2.c
@@ -19,6 +19,7 @@
#include <sys/stat.h>
static char *progname;
+static unsigned int xtra_offset;
static unsigned char eof_mark[4] = {0xde, 0xad, 0xc0, 0xde};
#define ERR(fmt, ...) do { \
@@ -63,6 +64,8 @@ static int pad_image(char *name, uint32_t pad_mask)
memset(buf, '\xff', BUF_SIZE);
+ in_len += xtra_offset;
+
out_len = in_len;
while (pad_mask) {
uint32_t mask;
@@ -83,7 +86,7 @@ static int pad_image(char *name, uint32_t pad_mask)
pad_mask &= ~mask;
}
- printf("padding image to %08x\n", (unsigned int) in_len);
+ printf("padding image to %08x\n", (unsigned int) in_len - xtra_offset);
while (out_len < in_len) {
ssize_t len;
@@ -131,14 +134,22 @@ int main(int argc, char* argv[])
if (argc < 2) {
fprintf(stderr,
- "Usage: %s file [pad0] [pad1] [padN]\n",
+ "Usage: %s file [-x <xtra offset>] [pad0] [pad1] [padN]\n",
progname);
goto out;
}
pad_mask = 0;
- for (i = 2; i < argc; i++)
+ for (i = 2; i < argc; i++) {
+ if (i == 2 && strcmp(argv[i], "-x") == 0) {
+ i++;
+ xtra_offset = strtoul(argv[i], NULL, 0);
+ fprintf(stderr, "assuming %u bytes offset\n",
+ xtra_offset);
+ continue;
+ }
pad_mask |= strtoul(argv[i], NULL, 0) * 1024;
+ }
if (pad_mask == 0)
pad_mask = (4 * 1024) | (8 * 1024) | (64 * 1024) |