refresh kernel patches so that they apply cleanly
[openwrt/openwrt.git] / target / linux / generic-2.6 / patches / 204-jffs2_eofdetect.patch
1 diff -urN linux-2.6.21.1.old/fs/jffs2/build.c linux-2.6.21.1.dev/fs/jffs2/build.c
2 --- linux-2.6.21.1.old/fs/jffs2/build.c 2007-04-27 23:49:26.000000000 +0200
3 +++ linux-2.6.21.1.dev/fs/jffs2/build.c 2007-05-26 20:52:04.425726968 +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-2.6.21.1.old/fs/jffs2/scan.c linux-2.6.21.1.dev/fs/jffs2/scan.c
23 --- linux-2.6.21.1.old/fs/jffs2/scan.c 2007-04-27 23:49:26.000000000 +0200
24 +++ linux-2.6.21.1.dev/fs/jffs2/scan.c 2007-05-26 20:52:04.491716936 +0200
25 @@ -143,9 +143,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 @@ -546,6 +549,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