]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_is_floppy): New
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 15 Sep 2010 13:30:43 +0000 (15:30 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Wed, 15 Sep 2010 13:30:43 +0000 (15:30 +0200)
function.
* include/grub/emu/hostdisk.h (grub_util_biosdisk_is_floppy): New proto.
* util/grub-setup.c (setup): Use grub_util_biosdisk_is_floppy.

ChangeLog
grub-core/kern/emu/hostdisk.c
include/grub/emu/hostdisk.h
util/grub-setup.c

index 1113b8157df1cf4d21eb005c7eb55840c184bb08..b3f3c0e51a3032023ff59f3986d244298858f747 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-15  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/kern/emu/hostdisk.c (grub_util_biosdisk_is_floppy): New
+       function.
+       * include/grub/emu/hostdisk.h (grub_util_biosdisk_is_floppy): New proto.
+       * util/grub-setup.c (setup): Use grub_util_biosdisk_is_floppy.
+
 2010-09-15  Yves Blusseau  <blusseau@zetam.org>
 
        Add function to get completions from usage.
index 142e93fe2847610185df4cd2e5a358d81b67e69c..edf8dc219658c40134fa2a5773dc241eedc21dbf 100644 (file)
@@ -1575,3 +1575,29 @@ grub_util_biosdisk_get_osdev (grub_disk_t disk)
 {
   return map[disk->id].device;
 }
+
+int
+grub_util_biosdisk_is_floppy (grub_disk_t disk)
+{
+  struct stat st;
+  int fd;
+
+  fd = open (map[disk->id].device, O_RDONLY);
+  /* Shouldn't happen.  */
+  if (fd == -1)
+    return 0;
+
+  /* Shouldn't happen either.  */
+  if (fstat (fd, &st) < 0)
+    return 0;
+
+#if defined(__NetBSD__)
+  if (major(st.st_rdev) == RAW_FLOPPY_MAJOR)
+    return 1;
+#endif
+
+  if (major(st.st_rdev) == FLOPPY_MAJOR)
+    return 1;
+
+  return 0;
+}
index 5873aa4404c0207cefef9529f502388275ede85b..d8cc02e145d667bb3516bb0c166c3f1cede06eb5 100644 (file)
@@ -27,5 +27,6 @@ void grub_util_biosdisk_fini (void);
 char *grub_util_biosdisk_get_grub_dev (const char *os_dev);
 const char *grub_util_biosdisk_get_osdev (grub_disk_t disk);
 int grub_util_biosdisk_is_present (const char *name);
+int grub_util_biosdisk_is_floppy (grub_disk_t disk);
 
 #endif /* ! GRUB_BIOSDISK_MACHINE_UTIL_HEADER */
index 55d740f09a9a57b8beaa75944b1332457e0a5dd2..a95f9b9d59ca744207c540128c2f37abd6d46772 100644 (file)
@@ -339,8 +339,8 @@ setup (const char *dir,
     /* If DEST_DRIVE is a hard disk, enable the workaround, which is
        for buggy BIOSes which don't pass boot drive correctly. Instead,
        they pass 0x00 or 0x01 even when booted from 0x80.  */
-    if (dest_dev->disk->id & 0x80)
-    /* Replace the jmp (2 bytes) with double nop's.  */
+    if (!grub_util_biosdisk_is_floppy (dest_dev->disk))
+      /* Replace the jmp (2 bytes) with double nop's.  */
       *boot_drive_check = 0x9090;
   }
 #endif