]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* stage2/fsys_fat.c: Fix missdetection of ext2fs as fatfs.
authorrobertmh <robertmh@localhost>
Fri, 5 Sep 2003 01:36:58 +0000 (01:36 +0000)
committerrobertmh <robertmh@localhost>
Fri, 5 Sep 2003 01:36:58 +0000 (01:36 +0000)
ChangeLog
stage2/fsys_fat.c

index 83590d0a03d75d9e86b22c9923a2adbc11af47e8..ae04c0f535858166d18d31d257d51dfe5a75f185 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-09-05  KB Sriram  <mail_kb@yahoo.com>
+
+       * stage2/fsys_fat.c: Fix missdetection of ext2fs as fatfs.
+
 2003-09-05  Robert Millan  <robertmh@gnu.org>
 
        * docs/menu.lst (GNU/Linux): Add commented initrd command, which is
index 286d4a45fd6cc69025bdfe4394e400e6415d7ded..c97eb3c161e18342e90d2db1a245186fa02e6c13 100644 (file)
@@ -67,6 +67,7 @@ int
 fat_mount (void)
 {
   struct fat_bpb bpb;
+  __u32 magic, first_fat;
   
   /* Check partition type for harddisk */
   if (((current_drive & 0x80) || (current_slice != 0))
@@ -161,6 +162,31 @@ fat_mount (void)
          > FAT_SUPER->fat_length))
     return 0;
   
+  /* kbs: Media check on first FAT entry [ported from PUPA] */
+
+  if (!devread(FAT_SUPER->fat_offset, 0,
+               sizeof(first_fat), (char *)&first_fat))
+    return 0;
+
+  if (FAT_SUPER->fat_size == 8)
+    {
+      first_fat &= 0x0fffffff;
+      magic = 0x0fffff00;
+    }
+  else if (FAT_SUPER->fat_size == 4)
+    {
+      first_fat &= 0x0000ffff;
+      magic = 0xff00;
+    }
+  else
+    {
+      first_fat &= 0x00000fff;
+      magic = 0x0f00;
+    }
+
+  if (first_fat != (magic | bpb.media))
+    return 0;
+
   FAT_SUPER->cached_fat = - 2 * FAT_CACHE_SIZE;
   return 1;
 }