Commit 1f690869 authored by Andries E. Brouwer's avatar Andries E. Brouwer Committed by Linus Torvalds

[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.
parent d6e0320f
...@@ -964,13 +964,17 @@ int fat_fill_super(struct super_block *sb, void *data, int silent, ...@@ -964,13 +964,17 @@ int fat_fill_super(struct super_block *sb, void *data, int silent,
error = first; error = first;
goto out_fail; goto out_fail;
} }
if (FAT_FIRST_ENT(sb, media) != first if (FAT_FIRST_ENT(sb, media) == first) {
&& (media != 0xf8 || FAT_FIRST_ENT(sb, 0xfe) != first)) { /* all is as it should be */
if (!silent) { } 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 " printk(KERN_ERR "FAT: invalid first entry of FAT "
"(0x%x != 0x%x)\n", "(0x%x != 0x%x)\n",
FAT_FIRST_ENT(sb, media), first); FAT_FIRST_ENT(sb, media), first);
}
goto out_invalid; goto out_invalid;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment