JFFS: rmdir wierdness
Hi,
# mkdir a # ls a # rmdir a # ls # mkdir a mkdir: a: File exists
Also
# mkdir b # touch b/a # rm b/a # rmdir b rmdir: b: Directory not empty
rmdir() thinks `b' still has children (I think).
This was done with the latest CVS with kernel 2.2.18.
David Vrabel.
To unsubscribe, send "unsubscribe mtd" to [email protected]
Hi,
Are these problems anything to do with jffs_find_child() not ignoring deleted files?
David Vrabel
To unsubscribe, send "unsubscribe mtd" to [email protected]
Quoted 10 lines · [email protected] said:
# mkdir a # ls a # rmdir a # ls # mkdir a mkdir: a: File existsAlso
Quoted 7 lines
# mkdir b # touch b/a # rm b/a # rmdir b rmdir: b: Directory not empty
rmdir()thinks `b' still has children (I think).
More problems with the deletion code since I did the use counts. Hmmm. This was sort of why I didn't want to commit it immediately, till I'd had time to do some sanity checks on it.
Try this:
Index: intrep.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/intrep.c,v
retrieving revision 1.84
intrep.c +1 -1
@@ -1387,7 +1387,7 @@D3 (printk ("jffs_find_child()\n" ));for (f = dir->children; f; f = f->sibling_next) { -if (f->name +if (!f->deleted && f->name && !strncmp (f->name, name, len) && f->name[len] =='\0' ) {break ;
--
dwmw2
To unsubscribe, send "unsubscribe mtd" to [email protected]
Hi,
Quoted 7 lines
# mkdir a # ls a # rmdir a # ls # mkdir a mkdir: a: File exists
This one has been fixed.
Quoted 5 lines
# mkdir b # touch b/a # rm b/a # rmdir b rmdir: b: Directory not empty
This one is still broken.
In jffs_remove():
if (S_ISDIR(type)) {
/* ... */
if (del_f->children) {
result = -ENOTEMPTY;
goto jffs_remove_end;
}
}As I understand it del_f->children is the head of a list of the directory's children. If this is the case then won't you have to go through the list checking that all the children have been deleted? Find a patch that does just this (it works too).
David Vrabel.
Index: inode-v22.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v22.c,v
retrieving revision 1.55
12/18 14:05:50 renamed from 12/18 12:11:08 1.55 +2 -0
@@ -960,14 +960,20 @@ } if (S_ISDIR(type)) { + struct jffs_file *child=del_f->children; + result = -ENOTDIR; if (!S_ISDIR(del_f->mode)) { /* Is this really needed
for 2.2? */
D(printk("jffs_remove(): S_ISDIR but isn't\n"));
goto jffs_remove_end;
}- if (del_f->children) {
- result = -ENOTEMPTY;
- goto jffs_remove_end;
+
+ while(child) {
+ if( !child->deleted ) {
+ result = -ENOTEMPTY;
+ goto jffs_remove_end;
+ }
+ child = child->sibling_next;
}
}
else if (S_ISDIR(del_f->mode)) {Index: inode-v23.c
===================================================================
RCS file: /home/cvs/mtd/fs/jffs/inode-v23.c,v
retrieving revision 1.52
12/18 14:05:56 renamed from 12/18 12:11:08 1.52 +8 -4
@@ -956,11 +956,15 @@ } if (S_ISDIR(type)) { - if (del_f->children) { - result = -ENOTEMPTY; - goto jffs_remove_end; + struct jffs_file *child=del_f->children; + while(child) { + if( !child->deleted ) { + result = -ENOTEMPTY; + goto jffs_remove_end; + } + child = child->sibling_next; } - } + } else if (S_ISDIR(del_f->mode)) { D(printk("jffs_remove(): node is a directory " "but it shouldn't be.\n"));
To unsubscribe, send "unsubscribe mtd" to [email protected]