[patch] Fix too stricts sanity checks in FATfs

From: Vojtech Pavlik
Date: Thu Sep 23 2004 - 10:03:35 EST



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.

--- linus/fs/fat/inode.c 2004-08-25 11:34:17.665758665 +0200
+++ input/fs/fat/inode.c 2004-08-25 11:23:47.000000000 +0200
@@ -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 */

--
Vojtech Pavlik
SuSE Labs, SuSE CR
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/