From 1f690869108c01d824161324c5c37d00d40b356b Mon Sep 17 00:00:00 2001 From: "Andries E. Brouwer" Date: Sat, 25 Oct 2003 17:11:03 -0800 Subject: [PATCH] [PATCH] Relax FATFS validity tests The first FAT entry should have the media byte (0xf0,0xf8,...,0xff) extended with all 1 bits in the first FAT entry. Checking this is a good idea, it prevents us from mounting garbage as FAT - there is no good magic for FAT. Unfortunately, Windows does not enforce this, and 2.4 doesn't either. It turns out that there are filesystems around (two reports so far) that have a zero first FAT entry, and work under Windows and 2.4 but fail to mount under 2.6. So, this weakens the test. --- fs/fat/inode.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/fs/fat/inode.c b/fs/fat/inode.c index 72ed4f97a8ae5..11f64401f1bdc 100644 --- a/fs/fat/inode.c +++ b/fs/fat/inode.c @@ -964,13 +964,17 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, error = first; goto out_fail; } - if (FAT_FIRST_ENT(sb, media) != first - && (media != 0xf8 || FAT_FIRST_ENT(sb, 0xfe) != first)) { - if (!silent) { + if (FAT_FIRST_ENT(sb, media) == first) { + /* all is as it should be */ + } else if (media == 0xf8 && FAT_FIRST_ENT(sb, 0xfe) == first) { + /* bad, reported on pc9800 */ + } else if (first == 0) { + /* bad, reported with a SmartMedia card */ + } else { + if (!silent) printk(KERN_ERR "FAT: invalid first entry of FAT " "(0x%x != 0x%x)\n", FAT_FIRST_ENT(sb, media), first); - } goto out_invalid; } -- 2.53.0