1 Index: linux-2.4.35.4/fs/jffs2/build.c
2 ===================================================================
3 --- linux-2.4.35.4.orig/fs/jffs2/build.c 2007-12-15 05:19:38.778630906 +0100
4 +++ linux-2.4.35.4/fs/jffs2/build.c 2007-12-15 05:20:03.936064549 +0100
6 * provisions above, a recipient may use your version of this file
7 * under either the RHEPL or the GPL.
9 + * Modification for automatically cleaning the filesystem after
10 + * a specially marked block
11 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
13 * $Id: build.c,v 1.16.2.3 2003/04/30 09:43:32 dwmw2 Exp $
17 #include <linux/kernel.h>
18 #include <linux/jffs2.h>
19 #include <linux/slab.h>
20 +#include <linux/mtd/mtd.h>
23 int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
28 + if (c->flags & (1 << 7)) {
29 + printk("%s(): unlocking the mtd device... ", __func__);
31 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
34 + printk("%s(): erasing all blocks after the end marker... ", __func__);
35 + jffs2_erase_pending_blocks(c);
36 + jffs2_mark_erased_blocks(c);
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 2007-12-15 05:19:38.786631361 +0100
46 +++ linux-2.4.35.4/fs/jffs2/scan.c 2007-12-15 05:20:03.948065230 +0100
48 * provisions above, a recipient may use your version of this file
49 * under either the RHEPL or the GPL.
51 + * Modification for automatically cleaning the filesystem after
52 + * a specially marked block
53 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
55 * $Id: scan.c,v 1.51.2.4 2003/11/02 13:51:18 dwmw2 Exp $
59 for (i=0; i<c->nr_blocks; i++) {
60 struct jffs2_eraseblock *jeb = &c->blocks[i];
62 - ret = jffs2_scan_eraseblock(c, jeb);
64 + if (c->flags & (1 << 7))
67 + ret = jffs2_scan_eraseblock(c, jeb);
74 while(ofs < jeb->offset + c->sector_size) {
76 + unsigned char *buf = (unsigned char *) &node;
77 ACCT_PARANOIA_CHECK(jeb);
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) &&
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);
98 D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", sizeof(node), ofs, err));