3 @@ -114,6 +114,16 @@ static int jffs2_build_filesystem(struct
4 dbg_fsbuild("scanned flash completely\n");
5 jffs2_dbg_dump_block_lists_nolock(c);
7 + if (c->flags & (1 << 7)) {
8 + printk("%s(): unlocking the mtd device... ", __func__);
9 + mtd_unlock(c->mtd, 0, c->mtd->size);
12 + printk("%s(): erasing all blocks after the end marker... ", __func__);
13 + jffs2_erase_pending_blocks(c, -1);
17 dbg_fsbuild("pass 1 starting\n");
18 c->flags |= JFFS2_SB_FLAG_BUILDING;
19 /* Now scan the directory tree, increasing nlink according to every dirent found. */
22 @@ -148,8 +148,14 @@ int jffs2_scan_medium(struct jffs2_sb_in
23 /* reset summary info for next eraseblock scan */
24 jffs2_sum_reset_collected(s);
26 - ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
28 + if (c->flags & (1 << 7)) {
29 + if (mtd_block_isbad(c->mtd, jeb->offset))
30 + ret = BLK_STATE_BADBLOCK;
32 + ret = BLK_STATE_ALLFF;
34 + ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
39 @@ -556,6 +562,17 @@ static int jffs2_scan_eraseblock (struct
43 + if ((buf[0] == 0xde) &&
47 + /* end of filesystem. erase everything after this point */
48 + printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
49 + c->flags |= (1 << 7);
51 + return BLK_STATE_ALLFF;
54 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
56 max_ofs = EMPTY_SCAN_SIZE(c->sector_size);