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