backport jffs2 eof detect changes from 2.6
SVN-Revision: 4062
This commit is contained in:
parent
ef6788dd04
commit
9a2279b3f5
@ -1,6 +1,47 @@
|
|||||||
|
diff -ur linux.old/fs/jffs2/build.c linux.dev/fs/jffs2/build.c
|
||||||
|
--- linux.old/fs/jffs2/build.c 2003-06-13 16:51:37.000000000 +0200
|
||||||
|
+++ linux.dev/fs/jffs2/build.c 2006-06-23 22:15:21.000000000 +0200
|
||||||
|
@@ -31,6 +31,10 @@
|
||||||
|
* provisions above, a recipient may use your version of this file
|
||||||
|
* under either the RHEPL or the GPL.
|
||||||
|
*
|
||||||
|
+ * Modification for automatically cleaning the filesystem after
|
||||||
|
+ * a specially marked block
|
||||||
|
+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
|
||||||
|
+ *
|
||||||
|
* $Id: build.c,v 1.16.2.3 2003/04/30 09:43:32 dwmw2 Exp $
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@@ -38,6 +42,7 @@
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
#include <linux/jffs2.h>
|
||||||
|
#include <linux/slab.h>
|
||||||
|
+#include <linux/mtd/mtd.h>
|
||||||
|
#include "nodelist.h"
|
||||||
|
|
||||||
|
int jffs2_build_inode_pass1(struct jffs2_sb_info *, struct jffs2_inode_cache *);
|
||||||
|
@@ -89,6 +94,18 @@
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
+ if (c->flags & (1 << 7)) {
|
||||||
|
+ printk("%s(): unlocking the mtd device... ", __func__);
|
||||||
|
+ if (c->mtd->unlock)
|
||||||
|
+ c->mtd->unlock(c->mtd, 0, c->mtd->size);
|
||||||
|
+ printk("done.\n");
|
||||||
|
+
|
||||||
|
+ printk("%s(): erasing all blocks after the end marker... ", __func__);
|
||||||
|
+ jffs2_erase_pending_blocks(c);
|
||||||
|
+ jffs2_mark_erased_blocks(c);
|
||||||
|
+ printk("done.\n");
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
D1(printk(KERN_DEBUG "Scanned flash completely\n"));
|
||||||
|
/* Now build the data map for each inode, marking obsoleted nodes
|
||||||
|
as such, and also increase nlink of any children. */
|
||||||
diff -ur linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
|
diff -ur linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
|
||||||
--- linux.old/fs/jffs2/scan.c 2003-11-28 19:26:21.000000000 +0100
|
--- linux.old/fs/jffs2/scan.c 2006-06-23 21:57:32.000000000 +0200
|
||||||
+++ linux.dev/fs/jffs2/scan.c 2006-06-22 00:29:02.000000000 +0200
|
+++ linux.dev/fs/jffs2/scan.c 2006-06-23 22:01:35.000000000 +0200
|
||||||
@@ -31,6 +31,10 @@
|
@@ -31,6 +31,10 @@
|
||||||
* provisions above, a recipient may use your version of this file
|
* provisions above, a recipient may use your version of this file
|
||||||
* under either the RHEPL or the GPL.
|
* under either the RHEPL or the GPL.
|
||||||
@ -26,38 +67,7 @@ diff -ur linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
@@ -145,15 +154,23 @@
|
@@ -181,6 +190,7 @@
|
||||||
c->nr_erasing_blocks++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- /* Rotate the lists by some number to ensure wear levelling */
|
|
||||||
- jffs2_rotate_lists(c);
|
|
||||||
|
|
||||||
- if (c->nr_erasing_blocks) {
|
|
||||||
- if (!c->used_size && empty_blocks != c->nr_blocks) {
|
|
||||||
- printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");
|
|
||||||
- return -EIO;
|
|
||||||
+ if (c->flags & (1 << 7)) {
|
|
||||||
+ printk("jffs2_scan_medium(): erasing all blocks after the end marker...\n");
|
|
||||||
+ jffs2_erase_pending_blocks(c);
|
|
||||||
+ jffs2_mark_erased_blocks(c);
|
|
||||||
+ printk("jffs2_scan_medium(): done.\n");
|
|
||||||
+ } else {
|
|
||||||
+ /* Rotate the lists by some number to ensure wear levelling */
|
|
||||||
+ jffs2_rotate_lists(c);
|
|
||||||
+
|
|
||||||
+ if (c->nr_erasing_blocks) {
|
|
||||||
+ if (!c->used_size && empty_blocks != c->nr_blocks) {
|
|
||||||
+ printk(KERN_NOTICE "Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes\n");
|
|
||||||
+ return -EIO;
|
|
||||||
+ }
|
|
||||||
+ jffs2_erase_pending_trigger(c);
|
|
||||||
}
|
|
||||||
- jffs2_erase_pending_trigger(c);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -181,6 +197,7 @@
|
|
||||||
|
|
||||||
while(ofs < jeb->offset + c->sector_size) {
|
while(ofs < jeb->offset + c->sector_size) {
|
||||||
ssize_t retlen;
|
ssize_t retlen;
|
||||||
@ -65,7 +75,7 @@ diff -ur linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
|
|||||||
ACCT_PARANOIA_CHECK(jeb);
|
ACCT_PARANOIA_CHECK(jeb);
|
||||||
|
|
||||||
if (ofs & 3) {
|
if (ofs & 3) {
|
||||||
@@ -202,8 +219,18 @@
|
@@ -202,8 +212,18 @@
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,4 +95,3 @@ diff -ur linux.old/fs/jffs2/scan.c linux.dev/fs/jffs2/scan.c
|
|||||||
if (err) {
|
if (err) {
|
||||||
D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", sizeof(node), ofs, err));
|
D1(printk(KERN_WARNING "mtd->read(0x%x bytes from 0x%x) returned %d\n", sizeof(node), ofs, err));
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user