1 Index: linux-2.6.25.1/fs/jffs2/build.c
2 ===================================================================
3 --- linux-2.6.25.1.orig/fs/jffs2/build.c
4 +++ linux-2.6.25.1/fs/jffs2/build.c
5 @@ -105,6 +105,17 @@ static int jffs2_build_filesystem(struct
6 dbg_fsbuild("scanned flash completely\n");
7 jffs2_dbg_dump_block_lists_nolock(c);
9 + if (c->flags & (1 << 7)) {
10 + printk("%s(): unlocking the mtd device... ", __func__);
12 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
15 + printk("%s(): erasing all blocks after the end marker... ", __func__);
16 + jffs2_erase_pending_blocks(c, -1);
20 dbg_fsbuild("pass 1 starting\n");
21 c->flags |= JFFS2_SB_FLAG_BUILDING;
22 /* Now scan the directory tree, increasing nlink according to every dirent found. */
23 Index: linux-2.6.25.1/fs/jffs2/scan.c
24 ===================================================================
25 --- linux-2.6.25.1.orig/fs/jffs2/scan.c
26 +++ linux-2.6.25.1/fs/jffs2/scan.c
27 @@ -142,9 +142,12 @@ int jffs2_scan_medium(struct jffs2_sb_in
29 /* reset summary info for next eraseblock scan */
30 jffs2_sum_reset_collected(s);
32 - ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
35 + if (c->flags & (1 << 7))
36 + ret = BLK_STATE_ALLFF;
38 + ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
43 @@ -545,6 +548,17 @@ static int jffs2_scan_eraseblock (struct
47 + if ((buf[0] == 0xde) &&
51 + /* end of filesystem. erase everything after this point */
52 + printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
53 + c->flags |= (1 << 7);
55 + return BLK_STATE_ALLFF;
58 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */