Skip to contentSkip to conversation

Fix too stricts sanity checks in FATfs

PATCH New Vojtech Pavlik 1 participant 1 message Sep 23, 2004 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix too stricts sanity checks in FATfs

This patch fixes a too strict sanity check in the FAT code, allowing to mount the flash memory in Nokia phones, as well as in several other devices.

The FAT standard allows for the first entries to be -1 to -8 in the n-bit encoding, however Linux currently insists on -1 only.

fs/fat/inode.c +5 -4
@@ -999,11 +999,12 @@
 		error = first;
 		goto out_fail;
 	}
-	if (FAT_FIRST_ENT(sb, media) == first) {
-		/* all is as it should be */
-	} else if (media == 0xf8 && FAT_FIRST_ENT(sb, 0xfe) == first) {
+
+	if ((FAT_FIRST_ENT(sb, media) | 0x03) == first) {
+		/* all is as it should be: -1 to -8 */
+	} else if (media == 0xf8 && (FAT_FIRST_ENT(sb, 0xfe) | 0x03) == first) {
 		/* bad, reported on pc9800 */
-	} else if (media == 0xf0 && FAT_FIRST_ENT(sb, 0xf8) == first) {
+	} else if (media == 0xf0 && (FAT_FIRST_ENT(sb, 0xf8) | 0x03) == first) {
 		/* bad, reported with a MO disk on win95/me */
 	} else if (first == 0) {
 		/* bad, reported with a SmartMedia card */
Signature · 2 lines
Vojtech Pavlik
SuSE Labs, SuSE CR