defb53540124c634c0577556c45e6fe85d6b5dc8
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.24 / 204-jffs2_eofdetect.patch
1 Index: linux-2.6.24.7/fs/jffs2/build.c
2 ===================================================================
3 --- linux-2.6.24.7.orig/fs/jffs2/build.c
4 +++ linux-2.6.24.7/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);
8
9 + if (c->flags & (1 << 7)) {
10 + printk("%s(): unlocking the mtd device... ", __func__);
11 + if (c->mtd->unlock)
12 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
13 + printk("done.\n");
14 +
15 + printk("%s(): erasing all blocks after the end marker... ", __func__);
16 + jffs2_erase_pending_blocks(c, -1);
17 + printk("done.\n");
18 + }
19 +
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.24.7/fs/jffs2/scan.c
24 ===================================================================
25 --- linux-2.6.24.7.orig/fs/jffs2/scan.c
26 +++ linux-2.6.24.7/fs/jffs2/scan.c
27 @@ -142,9 +142,12 @@ int jffs2_scan_medium(struct jffs2_sb_in
28
29 /* reset summary info for next eraseblock scan */
30 jffs2_sum_reset_collected(s);
31 -
32 - ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
33 - buf_size, s);
34 +
35 + if (c->flags & (1 << 7))
36 + ret = BLK_STATE_ALLFF;
37 + else
38 + ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
39 + buf_size, s);
40
41 if (ret < 0)
42 goto out;
43 @@ -545,6 +548,17 @@ static int jffs2_scan_eraseblock (struct
44 return err;
45 }
46
47 + if ((buf[0] == 0xde) &&
48 + (buf[1] == 0xad) &&
49 + (buf[2] == 0xc0) &&
50 + (buf[3] == 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);
54 +
55 + return BLK_STATE_ALLFF;
56 + }
57 +
58 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
59 ofs = 0;
60
This page took 0.041513 seconds and 3 git commands to generate.