I don't know a thing about fat layout, but it appears that it uses a
linked list of blocks, and if that list ends up pointing back onto
itself, the kernel goes into an infinite loop in several places chasing
its way to the end of the list.
The below patch fixed it for me, and I was able to mount and read
your filesystem image.
Unless someone has a smarter fix, I'll send this to the kernel
maintainers in a week or two.
--- linux-2.4.18-pre3/fs/fat/misc.c Fri Oct 12 13:48:42 2001
+++ linux-akpm/fs/fat/misc.c Sat Jan 12 23:28:03 2002
@@ -478,6 +478,8 @@ static int raw_scan_nonroot(struct super
printk("raw_scan_nonroot: start=%d\n",start);
#endif
do {
+ int old_start = start;
+
for (count = 0; count < MSDOS_SB(sb)->cluster_size; count++) {
if ((cluster = raw_scan_sector(sb,(start-2)*
MSDOS_SB(sb)->cluster_size+MSDOS_SB(sb)->data_start+
@@ -486,6 +488,11 @@ static int raw_scan_nonroot(struct super
}
if (!(start = fat_access(sb,start,-1))) {
fat_fs_panic(sb,"FAT error");
+ break;
+ }
+ if (start == old_start) {
+ /* Prevent infinite loop on corrupt fs */
+ fat_fs_panic(sb, "FAT loop");
break;
}
#ifdef DEBUG
--- linux-2.4.18-pre3/fs/fat/inode.c Thu Nov 22 23:02:58 2001
+++ linux-akpm/fs/fat/inode.c Sat Jan 12 23:37:44 2002
@@ -392,12 +392,18 @@ static void fat_read_root(struct inode *
MSDOS_I(inode)->i_start = sbi->root_cluster;
if ((nr = MSDOS_I(inode)->i_start) != 0) {
while (nr != -1) {
+ int old_nr = nr;
inode->i_size += 1 << sbi->cluster_bits;
if (!(nr = fat_access(sb, nr, -1))) {
printk("Directory %ld: bad FAT\n",
inode->i_ino);
break;
}
+ if (nr == old_nr) {
+ printk("Directory %ld: FAT loop\n",
+ inode->i_ino);
+ break;
+ }
}
}
} else {
@@ -918,9 +924,15 @@ static void fat_fill_inode(struct inode
#endif
if ((nr = MSDOS_I(inode)->i_start) != 0)
while (nr != -1) {
+ int old_nr = nr;
inode->i_size += 1 << sbi->cluster_bits;
if (!(nr = fat_access(sb, nr, -1))) {
printk("Directory %ld: bad FAT\n",
+ inode->i_ino);
+ break;
+ }
+ if (nr == old_nr) {
+ printk("Directory %ld: FAT loop\n",
inode->i_ino);
break;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/