mtd/fs/jffs2 erase.c,1.91,1.92 wbuf.c,1.108,1.109

havasi at infradead.org havasi at infradead.org
Sat Jan 21 16:50:48 EST 2006


Update of /home/cvs/mtd/fs/jffs2
In directory phoenix.infradead.org:/tmp/cvs-serv21333

Modified Files:
	erase.c wbuf.c 
Log Message:
[JFFS2] EBH fixes

EBH related fixes written by Alexey Korolev.



Index: erase.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/erase.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -r1.91 -r1.92
--- erase.c	18 Nov 2005 07:27:45 -0000	1.91
+++ erase.c	21 Jan 2006 21:50:44 -0000	1.92
@@ -391,7 +391,7 @@
 		struct jffs2_raw_ebh ebh = {
 			.magic =        cpu_to_je16(JFFS2_MAGIC_BITMASK),
 			.nodetype =     cpu_to_je16(JFFS2_NODETYPE_ERASEBLOCK_HEADER),
-			.totlen =       cpu_to_je32(sizeof(struct jffs2_raw_ebh)),
+			.totlen =       cpu_to_je32(c->ebh_size),
 			.reserved =     0,
 			.compat_fset =  JFFS2_EBH_COMPAT_FSET,
 			.incompat_fset = JFFS2_EBH_INCOMPAT_FSET,

Index: wbuf.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/wbuf.c,v
retrieving revision 1.108
retrieving revision 1.109
diff -u -r1.108 -r1.109
--- wbuf.c	18 Nov 2005 07:27:45 -0000	1.108
+++ wbuf.c	21 Jan 2006 21:50:44 -0000	1.109
@@ -635,7 +635,7 @@
 	/* Fixup the wbuf if we are moving to a new eraseblock.  The checks below
 	   fail for ECC'd NOR because cleanmarker == 16, so a block starts at
 	   xxx0010.  */
-	if (jffs2_nor_ecc(c)) {
+	if (jffs2_nor_ecc(c) || jffs2_nor_wbuf_flash(c)) {
 		if (((c->wbuf_ofs % c->sector_size) == 0) && !c->wbuf_len) {
 			c->wbuf_ofs = PAGE_DIV(to);
 			c->wbuf_len = PAGE_MOD(to);
@@ -997,7 +997,7 @@
 	uint32_t oob_nr, total_len;
 	unsigned char *buf;
 	int ret;
-	struct jffs2_unknown_node *n;
+	struct jffs2_unknown_node *n, un;
 	struct jffs2_raw_ebh eh;
 	uint32_t read_in = 0, i = 0, copy_len, node_crc;
 
@@ -1028,7 +1028,16 @@
 		goto out;
 	}
 
-	n = (struct jffs2_unknown_node *) &buf[c->fsdata_pos];
+	i = 0;
+	read_in = 0;
+	while (read_in < sizeof(struct jffs2_unknown_node)) {
+		copy_len = min_t(uint32_t, c->fsdata_len, sizeof(struct jffs2_unknown_node) - read_in);
+		memcpy((unsigned char *)&un + read_in, &buf[oob_size*i + c->fsdata_pos], copy_len);
+		read_in += copy_len;
+		i++;
+	}
+	n = &un;
+
 	if (je16_to_cpu(n->magic) != JFFS2_MAGIC_BITMASK) {
 		D1 (printk(KERN_WARNING "jffs2_check_nand_cleanmarker_ebh(): Cleanmarker node not detected in block at %08x\n", jeb->offset));
 		ret = 1;
@@ -1045,6 +1054,8 @@
 		goto out;
 	}else if (je16_to_cpu(n->nodetype) == JFFS2_NODETYPE_ERASEBLOCK_HEADER) {
 		/* Read the scattered data(in buf[]) into struct jffs2_raw_ebh */
+		i = 0;
+		read_in = 0;
 		while (read_in < sizeof(struct jffs2_raw_ebh)) {
 			copy_len = min_t(uint32_t, c->fsdata_len, sizeof(struct jffs2_raw_ebh) - read_in);
 			memcpy((unsigned char *)&eh + read_in, &buf[oob_size*i + c->fsdata_pos], copy_len);
@@ -1052,7 +1063,7 @@
 			i++;
 		}
 
-		node_crc = crc32(0, &eh, sizeof(struct jffs2_raw_ebh)-8);
+		node_crc = crc32(0, &eh + sizeof(struct jffs2_unknown_node) + 4, sizeof(struct jffs2_raw_ebh) - sizeof(struct jffs2_unknown_node) - 4);
 		if (node_crc != je32_to_cpu(eh.node_crc)) {
 			ret = 1;
 			goto out;





More information about the linux-mtd-cvs mailing list