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

Possible bug in file truncation code

Hi Folks

Im tracking down a bug reported on the eCos mailing list. Please see
the thread:


In summary, the following causes the filesystem to be corrupted:

        fd = fopen("foobar", "w");

ie openning a file so that it gets truncated and then closing
it. There ie an eCos test case in the thread.

I've looked at the code. The achive the truncation eCos does:

jffs2_truncate_fraglist(c, &f->fragtree, 0);

this in turn does

jffs2_obsolete_node_frag(c, frag);

for every fragment the node has. jffs2_obsolete_node_frag() has this
bit of code:

      if (!this->node->frags) {
		/* The node has no valid frags left. It's totally obsoleted */
		D2(printk(KERN_DEBUG "Marking old node @0x%08x (0x%04x-0x%04x) obsolete\n",
			  ref_offset(this->node->raw), this->node->ofs, this->node->ofs+this->node->size));
		jffs2_mark_node_obsolete(c, this->node->raw);
	} else {

ie if the node does not have any fragments left its marked as
obsolete. These appears to remove the node, but still leaves it
referenced in the directory. Hence the filesystem is corrupt. Just
removing this bit of code does not seem to correctly fix the
problem. One of the other eCos test cases then fails....

So could somebody point me in the right direction for fixing this.


To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com