diff options
author | wbx <wbx@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2005-04-02 12:12:58 +0000 |
---|---|---|
committer | wbx <wbx@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2005-04-02 12:12:58 +0000 |
commit | 21db875713e9dab2d6560f121b8e856fd182a773 (patch) | |
tree | 242788637a26f3f16ea5b2cf9912f9274b46ad51 /package/openwrt | |
parent | 59cf9955ada396f84414e779e62d9742b7451d66 (diff) |
lzma loader patch from oleg, great thanks good work, saves another 300 kb flashmemory
git-svn-id: svn://svn.openwrt.org/openwrt/trunk/openwrt@513 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/openwrt')
-rw-r--r-- | package/openwrt/jffs2root.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/package/openwrt/jffs2root.c b/package/openwrt/jffs2root.c index e0cbfb94e0..d79532ea64 100644 --- a/package/openwrt/jffs2root.c +++ b/package/openwrt/jffs2root.c @@ -73,6 +73,8 @@ int main(int argc, char **argv) int fd; unsigned long len; struct trx_header *ptr; + unsigned offset; + if (((fd = open(FILENAME, O_RDWR)) < 0) || ((len = lseek(fd, 0, SEEK_END)) < 0) || ((ptr = (struct trx_header *) mmap(0, len, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0)) == (void *) (-1)) @@ -81,17 +83,20 @@ int main(int argc, char **argv) exit(-1); } + /* treat last partition as rootfs offset */ + offset = ptr->offsets[2] ? : ptr->offsets[1]; + if (argc > 1 && !strcmp(argv[1],"--move")) { - if (ptr->offsets[1] >= ptr->len) { + if (offset >= ptr->len) { printf("Partition already moved outside trx\n"); #if 0 - } else if (ptr->offsets[1] & 0x0001ffff) { + } else if (offset & 0x0001ffff) { printf("Partition does not start on a block boundary\n"); #endif } else { init_crc32(); //bzero((void *)((int)ptr + ptr->len), (size_t)(len - ptr->len)); - ptr->len = ptr->offsets[1]; + ptr->len = offset; ptr->crc32 = crc32buf((void *) &(ptr->flag_version), ptr->len - offsetof(struct trx_header, flag_version)); msync(ptr,len,MS_SYNC|MS_INVALIDATE); printf("Partition moved; please reboot\n"); |