[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

jffs_delete_data() doesn't split nodes when it should.




It looks to me as if the check in jffs_delete_data() for whether to split a 
node or not is backwards. Also, the calculation of fm_offset for the second 
part of the newly-split node was incorrect.

It now appears to mount the following four-node filesystem image correctly,
but I still can't get the JFFS code, in conjunction with the test program
that I posted earlier, to _create_ such a filesystem image. 

0000000 31 39 38 34 02 00 00 00 01 00 00 00 01 00 00 00
0000016 a0 81 00 00 00 00 00 00 c4 34 88 39 c4 34 88 39
0000032 c4 34 88 39 00 00 00 00 00 00 00 00 00 00 00 00
0000048 08 01 00 ff 00 00 00 00 60 03 92 07 74 65 73 74
0000064 66 69 6c 65 31 39 38 34 02 00 00 00 01 00 00 00
0000080 02 00 00 00 a0 81 00 00 00 00 00 00 c4 34 88 39
0000096 c4 34 88 39 c4 34 88 39 00 00 00 00 08 00 00 00
0000112 00 00 00 00 00 01 00 ff e7 02 00 00 00 00 19 08
0000128 54 68 72 75 6e 67 65 0a 31 39 38 34 02 00 00 00
0000144 01 00 00 00 03 00 00 00 a0 81 00 00 00 00 00 00
0000160 c4 34 88 39 c4 34 88 39 c4 34 88 39 08 00 00 00
0000176 07 00 00 00 00 00 00 00 00 01 00 ff 5f 02 00 00
0000192 00 00 99 07 57 69 62 62 6c 65 0a ff 31 39 38 34
0000208 02 00 00 00 01 00 00 00 04 00 00 00 a0 81 00 00
0000224 00 00 00 00 c4 34 88 39 c4 34 88 39 c4 34 88 39
0000240 02 00 00 00 02 00 00 00 02 00 00 00 00 01 00 ff
0000256 f0 00 00 00 00 00 20 08 78 78 ff ff ff ff ff ff
0000272 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff



Index: intrep.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/intrep.c,v
retrieving revision 1.26
diff -u -w -r1.26 intrep.c
--- intrep.c	2000/08/02 12:25:46	1.26
+++ intrep.c	2000/08/02 15:46:21
@@ -1737,7 +1737,7 @@
 	}
 	else if (n->data_offset < offset) {
 		/* See if the node has to be split into two parts.  */
-		if (n->data_offset + n->data_size < offset + remove_size) {
+		if (n->data_offset + n->data_size > offset + remove_size) {
 			/* Do the split.  */
 			struct jffs_node *new_node;
 			D3(printk("jffs_delete_data(): Split node with "
@@ -1754,11 +1754,8 @@
 			new_node->ino = n->ino;
 			new_node->version = n->version;
 			new_node->data_offset = offset;
-			new_node->data_size = n->data_size
-					      - (remove_size
-						 + (offset - n->data_offset));
-			new_node->fm_offset = n->fm_offset + n->data_size
-					      + remove_size;
+			new_node->data_size = n->data_size - (remove_size + (offset - n->data_offset));
+			new_node->fm_offset = n->fm_offset + (remove_size + (offset - n->data_offset));
 			new_node->name_size = n->name_size;
 			new_node->fm = n->fm;
 			new_node->version_prev = n;


--
dwmw2