1 diff -ur linux.old/fs/jffs2/build.c linux.dev/fs/jffs2/build.c
2 --- linux.old/fs/jffs2/build.c 2003-06-13 16:51:37.000000000 +0200
3 +++ linux.dev/fs/jffs2/build.c 2006-06-23 22:15:21.000000000 +0200
5 * provisions above, a recipient may use your version of this file
6 * under either the RHEPL or the GPL.
8 + * Modification for automatically cleaning the filesystem after
9 + * a specially marked block
10 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
12 * $Id: build.c,v 1.16.2.3 2003/04/30 09:43:32 dwmw2 Exp $
16 #include <linux/kernel.h>
17 #include <linux/jffs2.h>
18 #include <linux/slab.h>
19 +#include <linux/mtd/mtd.h>
22 int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
27 + if (c->flags & (1 << 7)) {
28 + printk("%s(): unlocking the mtd device... ", __func__);
30 + c->mtd->unlock(c->mtd, 0, c->mtd->size);
33 + printk("%s(): erasing all blocks after the end marker... ", __func__);
34 + jffs2_erase_pending_blocks(c);
35 + jffs2_mark_erased_blocks(c);
39 D1(printk(KERN_DEBUG "Scanned flash completely\n"));
40 /* Now build the data map for each inode, marking obsoleted nodes
41 as such, and also increase nlink of any children. */
42 diff -ur linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
43 --- linux.old/fs/jffs2/scan.c 2006-06-23 21:57:32.000000000 +0200
44 +++ linux.dev/fs/jffs2/scan.c 2006-06-23 22:01:35.000000000 +0200
46 * provisions above, a recipient may use your version of this file
47 * under either the RHEPL or the GPL.
49 + * Modification for automatically cleaning the filesystem after
50 + * a specially marked block
51 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
53 * $Id: scan.c,v 1.51.2.4 2003/11/02 13:51:18 dwmw2 Exp $
57 for (i=0; i<c->nr_blocks; i++) {
58 struct jffs2_eraseblock *jeb = &c->blocks[i];
60 - ret = jffs2_scan_eraseblock(c, jeb);
62 + if (c->flags & (1 << 7))
65 + ret = jffs2_scan_eraseblock(c, jeb);
72 while(ofs < jeb->offset + c->sector_size) {
74 + unsigned char *buf = (unsigned char *) &node;
75 ACCT_PARANOIA_CHECK(jeb);
82 - err = c->mtd->read(c->mtd, ofs, sizeof(node), &retlen, (char *)&node);
83 + err = c->mtd->read(c->mtd, ofs, sizeof(node), &retlen, buf);
84 + if ((buf[0] == 0xde) &&
89 + /* end of filesystem. erase everything after this point */
90 + c->flags |= (1 << 7);
91 + printk("jffs2_scan_eraseblock(): End of filesystem marker found at 0x%x\n", jeb->offset);
96 D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", sizeof(node), ofs, err));