bug-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] ext2 detected as MS-DOS


From: KB Sriram
Subject: [PATCH] ext2 detected as MS-DOS
Date: Tue, 2 Sep 2003 16:34:04 -0700 (PDT)

I'd like to offer this patch to address the "ext2
recognized as FAT"
issue. This typically happens when reformatting a
previously FAT
formatted floppy to an ext2 filesystem.

Following Okuji's suggestion on this thread:
http://mail.gnu.org/archive/html/bug-grub/2003-01/msg00044.html
http://mail.gnu.org/archive/html/bug-grub/2003-01/msg00041.html

I've transplanted his check in the PUPA code to GRUB.

Regards,
-kb


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
--- grub.orig/stage2/fsys_fat.c Sat Jan  4 15:26:16 2003
+++ grub/stage2/fsys_fat.c      Tue Sep  2 13:21:18 2003
@@ -67,6 +67,7 @@
 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_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;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]