mtd/fs/jffs2 nodelist.c,1.110,1.111 readinode.c,1.140,1.141

Artem Bityuckiy dedekind at infradead.org
Wed Aug 17 10:57:43 EDT 2005


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

Modified Files:
	nodelist.c readinode.c 
Log Message:
[JFFS2] bugfix: calculate CRC check starting point correctly

When data starts from the beginning of NAND page, 'len' must be zero, not
c->wbuf_page.
Also add few debugging messages.
Thanks to Zoltan Sogor for report.



Index: nodelist.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/nodelist.c,v
retrieving revision 1.110
retrieving revision 1.111
diff -u -r1.110 -r1.111
--- nodelist.c	17 Aug 2005 14:13:45 -0000	1.110
+++ nodelist.c	17 Aug 2005 14:57:39 -0000	1.111
@@ -413,7 +413,8 @@
 	/* Calculate how many bytes were already checked */
 	ofs = ref_offset(ref) + sizeof(struct jffs2_raw_inode);
 	len = ofs & (c->wbuf_pagesize - 1);
-	len = c->wbuf_pagesize - len;
+	if (likely(len))
+		len = c->wbuf_pagesize - len;
 
 	if (len >= tn->csize) {
 		JFFS2_DBG_READINODE("no need to check node at %#08x, data length %u, data starts at %#08x - it has already been checked.\n",

Index: readinode.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/readinode.c,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -r1.140 -r1.141
--- readinode.c	17 Aug 2005 13:46:23 -0000	1.140
+++ readinode.c	17 Aug 2005 14:57:39 -0000	1.141
@@ -272,9 +272,9 @@
 			buf = (unsigned char *)rd + sizeof(*rd);
 			/* len will be the read data length */
 			len = min_t(uint32_t, rdlen - sizeof(*rd), csize);
-			
-			if (len)
-				tn->partial_crc = crc = crc32(0, buf, len);
+			tn->partial_crc = crc32(0, buf, len);
+
+			JFFS2_DBG_READINODE("Calculates CRC (%#08x) for %d bytes, csize %d\n", tn->partial_crc, len, csize);
 
 			/* If we actually calculated the whole data CRC
 			 * and it is wrong, drop the node. */
@@ -327,8 +327,8 @@
 	else // normal case...
 		tn->fn->size = je32_to_cpu(rd->dsize);
 
-	JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x\n",
-		  ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize));
+	JFFS2_DBG_READINODE("dnode @%08x: ver %u, offset %#04x, dsize %#04x, csize %#04x\n",
+		  ref_offset(ref), je32_to_cpu(rd->version), je32_to_cpu(rd->offset), je32_to_cpu(rd->dsize), csize);
 	
 	jffs2_add_tn_to_tree(tn, tnp);
 





More information about the linux-mtd-cvs mailing list