mtd/fs/jffs2 erase.c,1.54,1.55

David Woodhouse dwmw2 at infradead.org
Thu Oct 16 06:21:13 EDT 2003


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

Modified Files:
	erase.c 
Log Message:
Write just the header of a cleanmarker, not extra random data from the stack.
Don't use ref_totlen()


Index: erase.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/erase.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- erase.c	16 Oct 2003 09:17:17 -0000	1.54
+++ erase.c	16 Oct 2003 10:21:10 -0000	1.55
@@ -370,29 +370,30 @@
 			.totlen =	cpu_to_je32(c->cleanmarker_size)
 		};
 
-		marker.hdr_crc = cpu_to_je32(crc32(0, &marker, je32_to_cpu(marker.totlen) - 4));
+		marker.hdr_crc = cpu_to_je32(crc32(0, &marker, sizeof(struct jffs2_unknown_node)-4));
 
-		ret = jffs2_flash_write(c, jeb->offset, je32_to_cpu(marker.totlen), &retlen, (char *)&marker);
+		/* We only write the header; the rest was noise or padding anyway */
+		ret = jffs2_flash_write(c, jeb->offset, sizeof(marker), &retlen, (char *)&marker);
 		if (ret) {
 			printk(KERN_WARNING "Write clean marker to block at 0x%08x failed: %d\n",
 			       jeb->offset, ret);
 			goto bad2;
 		}
-		if (retlen != je32_to_cpu(marker.totlen)) {
+		if (retlen != sizeof(marker)) {
 			printk(KERN_WARNING "Short write to newly-erased block at 0x%08x: Wanted %d, got %zd\n",
-			       jeb->offset, je32_to_cpu(marker.totlen), retlen);
+			       jeb->offset, sizeof(marker), retlen);
 			goto bad2;
 		}
 
 		marker_ref->next_in_ino = NULL;
 		marker_ref->next_phys = NULL;
 		marker_ref->flash_offset = jeb->offset | REF_NORMAL;
-		marker_ref->__totlen = PAD(je32_to_cpu(marker.totlen));
+		marker_ref->__totlen = c->cleanmarker_size;
 			
 		jeb->first_node = jeb->last_node = marker_ref;
 			
-		jeb->free_size = c->sector_size - ref_totlen(marker_ref);
-		jeb->used_size = ref_totlen(marker_ref);
+		jeb->free_size = c->sector_size - c->cleanmarker_size;
+		jeb->used_size = c->cleanmarker_size;
 		jeb->dirty_size = 0;
 		jeb->wasted_size = 0;
 	}




More information about the linux-mtd-cvs mailing list