summaryrefslogtreecommitdiff
path: root/package/mtd/src/mtd.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-07-25 17:28:32 +0000
committerFelix Fietkau <nbd@openwrt.org>2012-07-25 17:28:32 +0000
commit5832e754fbf502a7d2f2d7bee054eae1b6ad0520 (patch)
tree8a2b915ad4f00fe32ab28753d4b84e53dfaf31aa /package/mtd/src/mtd.c
parentadc2b21be85a6bf34698e9f6ee72e72d8e6f7d03 (diff)
downloadmtk-20170518-5832e754fbf502a7d2f2d7bee054eae1b6ad0520.zip
mtk-20170518-5832e754fbf502a7d2f2d7bee054eae1b6ad0520.tar.gz
mtk-20170518-5832e754fbf502a7d2f2d7bee054eae1b6ad0520.tar.bz2
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/mtd.c')
-rw-r--r--package/mtd/src/mtd.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c
index 92873ca..18efcf5 100644
--- a/package/mtd/src/mtd.c
+++ b/package/mtd/src/mtd.c
@@ -294,6 +294,7 @@ mtd_write(int imagefd, const char *mtd, char *fis_layout, size_t part_offset)
ssize_t r, w, e;
ssize_t skip = 0;
uint32_t offset = 0;
+ int jffs2_replaced = 0;
#ifdef FIS_SUPPORT
static struct fis_part new_parts[MAX_ARGS];
@@ -417,6 +418,7 @@ resume:
fprintf(stderr, "\nAppending jffs2 data from %s to %s...", jffs2file, mtd);
/* got an EOF marker - this is the place to add some jffs2 data */
skip = mtd_replace_jffs2(mtd, fd, e, jffs2file);
+ jffs2_replaced = 1;
/* don't add it again */
jffs2file = NULL;
@@ -482,6 +484,10 @@ resume:
offset = 0;
}
+ if (jffs2_replaced && trx_fixup) {
+ trx_fixup(fd, mtd);
+ }
+
if (!quiet)
fprintf(stderr, "\b\b\b\b ");
@@ -575,7 +581,7 @@ int main (int argc, char **argv)
force = 0;
buflen = 0;
quiet = 0;
- no_erase = 0;
+ no_erase = 0;
while ((ch = getopt(argc, argv,
#ifdef FIS_SUPPORT