diff options
author | Felix Fietkau <nbd@openwrt.org> | 2012-07-25 17:28:32 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2012-07-25 17:28:32 +0000 |
commit | 5832e754fbf502a7d2f2d7bee054eae1b6ad0520 (patch) | |
tree | 8a2b915ad4f00fe32ab28753d4b84e53dfaf31aa /package/mtd/src/trx.c | |
parent | adc2b21be85a6bf34698e9f6ee72e72d8e6f7d03 (diff) | |
download | upstream-5832e754fbf502a7d2f2d7bee054eae1b6ad0520.tar.gz upstream-5832e754fbf502a7d2f2d7bee054eae1b6ad0520.tar.bz2 upstream-5832e754fbf502a7d2f2d7bee054eae1b6ad0520.zip |
mtd: fix trx_fixup
With the BRCM47xx image I have built (Linksys E3000), there are additional
writes following the completion of "mtd_replace_jffs2" which invalidate the
'trx_fixup' performed by 'mtd_replace_jffs2'. Moving the 'trx_fixup' to somewhere
after all writes have completed fixes the problem. I also noticed that 'erasesize'
used to compute 'block_offset' in 'mtd_fixtrx' is used before it is computed by
'mtd_check_open'; moving the call to 'mtd_check_open' up a few lines fixes this.
Unlike 'mtd_fixtrx', 'trx_fixup' appears to assume that the TRX header is always at
offset 0; which may be the cause of the problem described in Ticket #8960.
Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
SVN-Revision: 32866
Diffstat (limited to 'package/mtd/src/trx.c')
-rw-r--r-- | package/mtd/src/trx.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/package/mtd/src/trx.c b/package/mtd/src/trx.c index d1aab36923..65c24404c2 100644 --- a/package/mtd/src/trx.c +++ b/package/mtd/src/trx.c @@ -154,15 +154,15 @@ mtd_fixtrx(const char *mtd, size_t offset) if (quiet < 2) fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset); - block_offset = offset & ~(erasesize - 1); - offset -= block_offset; - fd = mtd_check_open(mtd); if(fd < 0) { fprintf(stderr, "Could not open mtd device: %s\n", mtd); exit(1); } + block_offset = offset & ~(erasesize - 1); + offset -= block_offset; + if (block_offset + erasesize > mtdsize) { fprintf(stderr, "Offset too large, device size 0x%x\n", mtdsize); exit(1); |