[PATCH] FAT32 - invalid FSINFO offset fix

Max Cohan (mcohan@adnc.net)
Wed, 31 Mar 1999 01:11:35 -0800


This should fix all of the problems with:
fat_read_super: Did not find valid FSINFO signature. Found 0x534f4453

I finally got a chance to really look at the kernel and try
a few things instead of hypothesising about the problem.
It turned out to be a really simple bug in the code.
If the sector offset of the FSINFO table is 0, the offset
was being calculated by multiplying by 0...this pointed the
FSINFO offset to the wrong place. I jumped to the wrong
conclusion earlier because a lot of reports with the same
signature and the same problem. Here's the patch (against kernel 2.2.5)

Max Cohan

-----------8<---------------8<--------------8<--------------8<-----------

diff -u --new-file --recursive linux-2.2.5/fs/fat/inode.c linux/fs/fat/inode.c
--- linux-2.2.5/fs/fat/inode.c Mon Jan 4 10:08:28 1999
+++ linux/fs/fat/inode.c Wed Mar 31 01:06:05 1999
@@ -3,6 +3,10 @@
*
* Written 1992,1993 by Werner Almesberger
* VFAT extensions by Gordon Chaffee, merged with msdos fs by Henrik Storner
+ *
+ * Fixes:
+ *
+ * Max Cohan: Fixed invalid FSINFO offset when info_sector is 0
*/

#include <linux/version.h>
@@ -362,8 +366,17 @@
fat32 = 1;
MSDOS_SB(sb)->fat_length= CF_LE_W(b->fat32_length)*sector_mult;
MSDOS_SB(sb)->root_cluster = CF_LE_L(b->root_cluster);
- MSDOS_SB(sb)->fsinfo_offset =
- CF_LE_W(b->info_sector) * logical_sector_size + 0x1e0;
+ CF_LE_W(b->info_sector), logical_sector_size);
+
+ /* MC - if info_sector is 0, don't multiply by 0 */
+ if(CF_LE_W(b->info_sector) == 0) {
+ MSDOS_SB(sb)->fsinfo_offset =
+ logical_sector_size + 0x1e0;
+ } else {
+ MSDOS_SB(sb)->fsinfo_offset =
+ (CF_LE_W(b->info_sector) * logical_sector_size)
+ + 0x1e0;
+ }
if (MSDOS_SB(sb)->fsinfo_offset + sizeof(struct fat_boot_fsinfo) > sb->s_blocksize) {
printk("fat_read_super: Bad fsinfo_offset\n");
fat_brelse(sb, bh);

-
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/