brcm47xx: remove support for kernel 2.6.39
[openwrt.git] / target / linux / generic / patches-2.6.38 / 512-jffs2_eofdetect.patch
1 --- a/fs/jffs2/build.c
2 +++ b/fs/jffs2/build.c
3 @@ -112,6 +112,17 @@ 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 + if (c->mtd->unlock)
10 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
11 + printk("done.\n");
12 +
13 + printk("%s(): erasing all blocks after the end marker... ", __func__);
14 + jffs2_erase_pending_blocks(c, -1);
15 + printk("done.\n");
16 + }
17 +
18 dbg_fsbuild("pass 1 starting\n");
19 c->flags |= JFFS2_SB_FLAG_BUILDING;
20 /* Now scan the directory tree, increasing nlink according to every dirent found. */
21 --- a/fs/jffs2/scan.c
22 +++ b/fs/jffs2/scan.c
23 @@ -72,7 +72,7 @@ static int file_dirty(struct jffs2_sb_in
24 return ret;
25 if ((ret = jffs2_scan_dirty_space(c, jeb, jeb->free_size)))
26 return ret;
27 - /* Turned wasted size into dirty, since we apparently
28 + /* Turned wasted size into dirty, since we apparently
29 think it's recoverable now. */
30 jeb->dirty_size += jeb->wasted_size;
31 c->dirty_size += jeb->wasted_size;
32 @@ -144,8 +144,11 @@ int jffs2_scan_medium(struct jffs2_sb_in
33 /* reset summary info for next eraseblock scan */
34 jffs2_sum_reset_collected(s);
35
36 - ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
37 - buf_size, s);
38 + if (c->flags & (1 << 7))
39 + ret = BLK_STATE_ALLFF;
40 + else
41 + ret = jffs2_scan_eraseblock(c, jeb, buf_size?flashbuf:(flashbuf+jeb->offset),
42 + buf_size, s);
43
44 if (ret < 0)
45 goto out;
46 @@ -402,7 +405,7 @@ static int jffs2_scan_xref_node(struct j
47 if (!ref)
48 return -ENOMEM;
49
50 - /* BEFORE jffs2_build_xattr_subsystem() called,
51 + /* BEFORE jffs2_build_xattr_subsystem() called,
52 * and AFTER xattr_ref is marked as a dead xref,
53 * ref->xid is used to store 32bit xid, xd is not used
54 * ref->ino is used to store 32bit inode-number, ic is not used
55 @@ -475,7 +478,7 @@ static int jffs2_scan_eraseblock (struct
56 struct jffs2_sum_marker *sm;
57 void *sumptr = NULL;
58 uint32_t sumlen;
59 -
60 +
61 if (!buf_size) {
62 /* XIP case. Just look, point at the summary if it's there */
63 sm = (void *)buf + c->sector_size - sizeof(*sm);
64 @@ -491,9 +494,9 @@ static int jffs2_scan_eraseblock (struct
65 buf_len = sizeof(*sm);
66
67 /* Read as much as we want into the _end_ of the preallocated buffer */
68 - err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
69 + err = jffs2_fill_scan_buf(c, buf + buf_size - buf_len,
70 jeb->offset + c->sector_size - buf_len,
71 - buf_len);
72 + buf_len);
73 if (err)
74 return err;
75
76 @@ -512,9 +515,9 @@ static int jffs2_scan_eraseblock (struct
77 }
78 if (buf_len < sumlen) {
79 /* Need to read more so that the entire summary node is present */
80 - err = jffs2_fill_scan_buf(c, sumptr,
81 + err = jffs2_fill_scan_buf(c, sumptr,
82 jeb->offset + c->sector_size - sumlen,
83 - sumlen - buf_len);
84 + sumlen - buf_len);
85 if (err)
86 return err;
87 }
88 @@ -527,7 +530,7 @@ static int jffs2_scan_eraseblock (struct
89
90 if (buf_size && sumlen > buf_size)
91 kfree(sumptr);
92 - /* If it returns with a real error, bail.
93 + /* If it returns with a real error, bail.
94 If it returns positive, that's a block classification
95 (i.e. BLK_STATE_xxx) so return that too.
96 If it returns zero, fall through to full scan. */
97 @@ -548,6 +551,17 @@ static int jffs2_scan_eraseblock (struct
98 return err;
99 }
100
101 + if ((buf[0] == 0xde) &&
102 + (buf[1] == 0xad) &&
103 + (buf[2] == 0xc0) &&
104 + (buf[3] == 0xde)) {
105 + /* end of filesystem. erase everything after this point */
106 + printk("%s(): End of filesystem marker found at 0x%x\n", __func__, jeb->offset);
107 + c->flags |= (1 << 7);
108 +
109 + return BLK_STATE_ALLFF;
110 + }
111 +
112 /* We temporarily use 'ofs' as a pointer into the buffer/jeb */
113 ofs = 0;
114 max_ofs = EMPTY_SCAN_SIZE(c->sector_size);
115 @@ -673,7 +687,7 @@ scan_more:
116 scan_end = buf_len;
117 goto more_empty;
118 }
119 -
120 +
121 /* See how much more there is to read in this eraseblock... */
122 buf_len = min_t(uint32_t, buf_size, jeb->offset + c->sector_size - ofs);
123 if (!buf_len) {
124 @@ -909,7 +923,7 @@ scan_more:
125
126 D1(printk(KERN_DEBUG "Block at 0x%08x: free 0x%08x, dirty 0x%08x, unchecked 0x%08x, used 0x%08x, wasted 0x%08x\n",
127 jeb->offset,jeb->free_size, jeb->dirty_size, jeb->unchecked_size, jeb->used_size, jeb->wasted_size));
128 -
129 +
130 /* mark_node_obsolete can add to wasted !! */
131 if (jeb->wasted_size) {
132 jeb->dirty_size += jeb->wasted_size;
This page took 0.058043 seconds and 5 git commands to generate.