Root/target/linux/generic/patches-3.6/532-jffs2_eofdetect.patch

1--- a/fs/jffs2/build.c
2+++ b/fs/jffs2/build.c
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);
6 
7+ if (c->flags & (1 << 7)) {
8+ printk("%s(): unlocking the mtd device... ", __func__);
9+ mtd_unlock(c->mtd, 0, c->mtd->size);
10+ printk("done.\n");
11+
12+ printk("%s(): erasing all blocks after the end marker... ", __func__);
13+ jffs2_erase_pending_blocks(c, -1);
14+ printk("done.\n");
15+ }
16+
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. */
20--- a/fs/jffs2/scan.c
21+++ b/fs/jffs2/scan.c
22@@ -148,8 +148,11 @@ int jffs2_scan_medium(struct jffs2_sb_in
23         /* reset summary info for next eraseblock scan */
24         jffs2_sum_reset_collected(s);
25 
26- ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
27- buf_size, s);
28+ if (c->flags & (1 << 7))
29+ ret = BLK_STATE_ALLFF;
30+ else
31+ ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
32+ buf_size, s);
33 
34         if (ret < 0)
35             goto out;
36@@ -556,6 +559,17 @@ static int jffs2_scan_eraseblock (struct
37             return err;
38     }
39 
40+ if ((buf[0] == 0xde) &&
41+ (buf[1] == 0xad) &&
42+ (buf[2] == 0xc0) &&
43+ (buf[3] == 0xde)) {
44+ /* end of filesystem. erase everything after this point */
45+ printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
46+ c->flags |= (1 << 7);
47+
48+ return BLK_STATE_ALLFF;
49+ }
50+
51     /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
52     ofs = 0;
53     max_ofs = EMPTY_SCAN_SIZE(c->sector_size);
54

Archive Download this file



interactive