mtd/fs/jffs2 file.c,1.58.2.3,1.58.2.4

David Woodhouse dwmw2 at infradead.org
Fri Nov 8 12:33:55 EST 2002


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

Modified Files:
      Tag: jffs2-2_4-branch
	file.c 
Log Message:
Fix long-standing hole-related breakage that fsx-linux found

Index: file.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs2/file.c,v
retrieving revision 1.58.2.3
retrieving revision 1.58.2.4
diff -u -r1.58.2.3 -r1.58.2.4
--- file.c	7 Oct 2002 12:25:55 -0000	1.58.2.3
+++ file.c	8 Nov 2002 17:33:52 -0000	1.58.2.4
@@ -276,23 +276,32 @@
 			continue;
 		} else {
 			__u32 readlen;
-			readlen = min(frag->size, end - offset);
-			D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%x\n", frag->ofs, frag->ofs+readlen, frag->node->raw->flash_offset & ~3));
-			ret = jffs2_read_dnode(c, frag->node, pg_buf, frag->ofs - frag->node->ofs, readlen);
+			__u32 fragofs; /* offset within the frag to start reading */
+
+			fragofs = offset - frag->ofs;
+			readlen = min(frag->size - fragofs, end - offset);
+			D1(printk(KERN_DEBUG "Reading %d-%d from node at 0x%x\n", frag->ofs+fragofs, 
+				  fragofs+frag->ofs+readlen, frag->node->raw->flash_offset & ~3));
+			ret = jffs2_read_dnode(c, frag->node, pg_buf, fragofs + frag->ofs - frag->node->ofs, readlen);
 			D2(printk(KERN_DEBUG "node read done\n"));
 			if (ret) {
 				D1(printk(KERN_DEBUG"jffs2_readpage error %d\n",ret));
-				memset(pg_buf, 0, frag->size);
+				memset(pg_buf, 0, readlen);
 				ClearPageUptodate(pg);
 				SetPageError(pg);
 				kunmap(pg);
 				return ret;
 			}
+		
+			pg_buf += readlen;
+			offset += readlen;
+			frag = frag->next;
+			D2(printk(KERN_DEBUG "node read was OK. Looping\n"));
+			continue;
 		}
-		pg_buf += frag->size;
-		offset += frag->size;
-		frag = frag->next;
-		D2(printk(KERN_DEBUG "node read was OK. Looping\n"));
+		/* We can't ever get here. Unless I'm having a particularly stupid day */
+		printk(KERN_CRIT "dwmw2 is stupid. Reason #5325\n");
+		BUG();
 	}
 	D2(printk(KERN_DEBUG "readpage finishing\n"));
 	SetPageUptodate(pg);





More information about the linux-mtd-cvs mailing list