]> git.hungrycats.org Git - linux/commitdiff
[PATCH] Relax FATFS validity tests
authorAndries E. Brouwer <andries.brouwer@cwi.nl>
Sun, 26 Oct 2003 01:11:03 +0000 (17:11 -0800)
committerLinus Torvalds <torvalds@home.osdl.org>
Sun, 26 Oct 2003 01:11:03 +0000 (17:11 -0800)
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

index 72ed4f97a8ae5a9f931d209ea2da0beea1131201..11f64401f1bdca25c8252747c32ad28f3d9a7feb 100644 (file)
@@ -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;
        }