Changeset 32866


Ignore:
Timestamp:
2012-07-25T19:28:32+02:00 (6 years ago)
Author:
nbd
Message:

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@…>

Location:
trunk/package/mtd
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/mtd/Makefile

    r29779 r32866  
    1010 
    1111PKG_NAME:=mtd 
    12 PKG_RELEASE:=17 
     12PKG_RELEASE:=18 
    1313 
    1414PKG_BUILD_DIR := $(KERNEL_BUILD_DIR)/$(PKG_NAME) 
  • trunk/package/mtd/src/jffs2.c

    r24837 r32866  
    245245        free(buf); 
    246246 
    247         if (trx_fixup) { 
    248           trx_fixup(outfd, mtd); 
    249         } 
    250247        return (mtdofs - ofs); 
    251248} 
  • trunk/package/mtd/src/mtd.c

    r32600 r32866  
    295295        ssize_t skip = 0; 
    296296        uint32_t offset = 0; 
     297        int jffs2_replaced = 0; 
    297298 
    298299#ifdef FIS_SUPPORT 
     
    418419                                /* got an EOF marker - this is the place to add some jffs2 data */ 
    419420                                skip = mtd_replace_jffs2(mtd, fd, e, jffs2file); 
     421                                jffs2_replaced = 1; 
    420422 
    421423                                /* don't add it again */ 
     
    481483                buflen = 0; 
    482484                offset = 0; 
     485        } 
     486 
     487        if (jffs2_replaced && trx_fixup) { 
     488                trx_fixup(fd, mtd); 
    483489        } 
    484490 
     
    576582        buflen = 0; 
    577583        quiet = 0; 
    578   no_erase = 0; 
     584        no_erase = 0; 
    579585 
    580586        while ((ch = getopt(argc, argv, 
  • trunk/package/mtd/src/trx.c

    r28893 r32866  
    155155                fprintf(stderr, "Trying to fix trx header in %s at 0x%x...\n", mtd, offset); 
    156156 
    157         block_offset = offset & ~(erasesize - 1); 
    158         offset -= block_offset; 
    159  
    160157        fd = mtd_check_open(mtd); 
    161158        if(fd < 0) { 
     
    163160                exit(1); 
    164161        } 
     162 
     163        block_offset = offset & ~(erasesize - 1); 
     164        offset -= block_offset; 
    165165 
    166166        if (block_offset + erasesize > mtdsize) { 
Note: See TracChangeset for help on using the changeset viewer.