finally move buildroot-ng to trunk
[openwrt/staging/jogo.git] / target / linux / generic-2.6 / patches / 204-jffs2_eofdetect.patch
1 diff -urN linux.old/fs/jffs2/build.c linux.dev/fs/jffs2/build.c
2 --- linux.old/fs/jffs2/build.c 2006-06-18 03:49:35.000000000 +0200
3 +++ linux.dev/fs/jffs2/build.c 2006-06-23 21:46:48.000000000 +0200
4 @@ -107,6 +107,17 @@
5 dbg_fsbuild("scanned flash completely\n");
6 jffs2_dbg_dump_block_lists_nolock(c);
7
8 + if (c->flags & (1 << 7)) {
9 + printk("%s(): unlocking the mtd device... ", __func__);
10 + if (c->mtd->unlock)
11 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
12 + printk("done.\n");
13 +
14 + printk("%s(): erasing all blocks after the end marker... ", __func__);
15 + jffs2_erase_pending_blocks(c, -1);
16 + printk("done.\n");
17 + }
18 +
19 dbg_fsbuild("pass 1 starting\n");
20 c->flags |= JFFS2_SB_FLAG_BUILDING;
21 /* Now scan the directory tree, increasing nlink according to every dirent found. */
22 diff -urN linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
23 --- linux.old/fs/jffs2/scan.c 2006-06-23 21:39:38.000000000 +0200
24 +++ linux.dev/fs/jffs2/scan.c 2006-06-23 21:42:18.000000000 +0200
25 @@ -119,9 +119,12 @@
26
27 /* reset summary info for next eraseblock scan */
28 jffs2_sum_reset_collected(s);
29 -
30 - ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
31 - buf_size, s);
32 +
33 + if (c->flags & (1 << 7))
34 + ret = BLK_STATE_ALLFF;
35 + else
36 + ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
37 + buf_size, s);
38
39 if (ret < 0)
40 goto out;
41 @@ -389,6 +392,17 @@
42 return err;
43 }
44
45 + if ((buf[0] == 0xde) &&
46 + (buf[1] == 0xad) &&
47 + (buf[2] == 0xc0) &&
48 + (buf[3] == 0xde)) {
49 + /* end of filesystem. erase everything after this point */
50 + printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
51 + c->flags |= (1 << 7);
52 +
53 + return BLK_STATE_ALLFF;
54 + }
55 +
56 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
57 ofs = 0;
58