[ar71xx] refresh patches for 2.6.30
[openwrt.git] / target / linux / generic-2.4 / patches / 227-jffs2_eofdetect.patch
1 Index: linux-2.4.35.4/fs/jffs2/build.c
2 ===================================================================
3 --- linux-2.4.35.4.orig/fs/jffs2/build.c
4 +++ linux-2.4.35.4/fs/jffs2/build.c
5 @@ -31,6 +31,10 @@
6 * provisions above, a recipient may use your version of this file
7 * under either the RHEPL or the GPL.
8 *
9 + * Modification for automatically cleaning the filesystem after
10 + * a specially marked block
11 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
12 + *
13 * $Id: build.c,v 1.16.2.3 2003/04/30 09:43:32 dwmw2 Exp $
14 *
15 */
16 @@ -38,6 +42,7 @@
17 #include <linux/kernel.h>
18 #include <linux/jffs2.h>
19 #include <linux/slab.h>
20 +#include <linux/mtd/mtd.h>
21 #include "nodelist.h"
22
23 int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
24 @@ -89,6 +94,18 @@ int jffs2_build_filesystem(struct jffs2_
25 if (ret)
26 return ret;
27
28 + if (c->flags & (1 << 7)) {
29 + printk("%s(): unlocking the mtd device... ", __func__);
30 + if (c->mtd->unlock)
31 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
32 + printk("done.\n");
33 +
34 + printk("%s(): erasing all blocks after the end marker... ", __func__);
35 + jffs2_erase_pending_blocks(c);
36 + jffs2_mark_erased_blocks(c);
37 + printk("done.\n");
38 + }
39 +
40 D1(printk(KERN_DEBUG "Scanned flash completely\n"));
41 /* Now build the data map for each inode, marking obsoleted nodes
42 as such, and also increase nlink of any children. */
43 Index: linux-2.4.35.4/fs/jffs2/scan.c
44 ===================================================================
45 --- linux-2.4.35.4.orig/fs/jffs2/scan.c
46 +++ linux-2.4.35.4/fs/jffs2/scan.c
47 @@ -31,6 +31,10 @@
48 * provisions above, a recipient may use your version of this file
49 * under either the RHEPL or the GPL.
50 *
51 + * Modification for automatically cleaning the filesystem after
52 + * a specially marked block
53 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
54 + *
55 * $Id: scan.c,v 1.51.2.4 2003/11/02 13:51:18 dwmw2 Exp $
56 *
57 */
58 @@ -88,7 +92,12 @@ int jffs2_scan_medium(struct jffs2_sb_in
59 for (i=0; i<c->nr_blocks; i++) {
60 struct jffs2_eraseblock *jeb = &c->blocks[i];
61
62 - ret = jffs2_scan_eraseblock(c, jeb);
63 +
64 + if (c->flags & (1 << 7))
65 + ret = 1;
66 + else
67 + ret = jffs2_scan_eraseblock(c, jeb);
68 +
69 if (ret < 0)
70 return ret;
71
72 @@ -181,6 +190,7 @@ static int jffs2_scan_eraseblock (struct
73
74 while(ofs < jeb->offset + c->sector_size) {
75 ssize_t retlen;
76 + unsigned char *buf = (unsigned char *) &node;
77 ACCT_PARANOIA_CHECK(jeb);
78
79 if (ofs & 3) {
80 @@ -202,8 +212,18 @@ static int jffs2_scan_eraseblock (struct
81 break;
82 }
83
84 - err = c->mtd->read(c->mtd, ofs, sizeof(node), &retlen, (char *)&node);
85 + err = c->mtd->read(c->mtd, ofs, sizeof(node), &retlen, buf);
86 + if ((buf[0] == 0xde) &&
87 + (buf[1] == 0xad) &&
88 + (buf[2] == 0xc0) &&
89 + (buf[3] == 0xde)) {
90 +
91 + /* end of filesystem. erase everything after this point */
92 + c->flags |= (1 << 7);
93 + printk("jffs2_scan_eraseblock(): End of filesystem marker found at 0x%x\n", jeb->offset);
94
95 + return 1;
96 + }
97 if (err) {
98 D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", sizeof(node), ofs, err));
99 return err;
This page took 0.04763 seconds and 5 git commands to generate.