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