[PATCH] Re: FAT panic when renaming directories

Alexander Viro (viro@math.psu.edu)
Sun, 28 Feb 1999 03:42:23 -0500 (EST)


On Sat, 27 Feb 1999, Brian Gerst wrote:

> I was renaming a bunch of directories on a FAT formatted ZIP disk when I
> got this message:
> Feb 27 08:14:59 citadel kernel: Filesystem panic (dev 08:04).
> Feb 27 08:14:59 citadel kernel: FAT error
> Feb 27 08:14:59 citadel kernel: File system has been set read-only
> Feb 27 08:14:59 citadel kernel: Directory 2444506: bad FAT
[snip]
> This is with kernel 2.2.1. Any ideas about what could be happening?
> I'm pretty sure that the corruption is in the FAT filesystem because the
> ZIP is SCSI and the hd is IDE.

Aaaarrrrgh... Yes, it's VFAT and the bug is still present in 2.2.2. Patch
follows:

diff -urN linux-2.2.2/fs/vfat/namei.c linux-bird.vfat-fix/fs/vfat/namei.c
--- linux-2.2.2/fs/vfat/namei.c Thu Feb 25 10:03:57 1999
+++ linux-bird.vfat-fix/fs/vfat/namei.c Sun Feb 28 03:22:16 1999
@@ -1659,6 +1659,9 @@
res = vfat_remove_entry(new_dir,&sinfo,new_inode);
if (res)
goto rename_done;
+
+ if (is_dir)
+ new_dir->i_nlink--;
}

/* Serious lossage here. FAT uses braindead inode numbers scheme,
@@ -1669,9 +1672,6 @@
* in icache and as a part of stat output. It would kill all the
* 'busy' stuff on the spot. Later.
*/
-
- if (is_dir)
- new_dir->i_nlink--;

res = vfat_find(new_dir,&new_dentry->d_name,1,is_dir,&sinfo);

Linus, apply it, please - it's a tail of the braino fixed back in
2.2.0-pre9. I've rechecked the thing now and there should be no stuff of
that sort left. It's commutative with the rename patch I've sent you.
Wearing the brown paperbag,
Al

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/