bug-grub
[Top][All Lists]
Advanced

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

a patch for working with HDD images and for newer Intel cards


From: Sergey Babkin
Subject: a patch for working with HDD images and for newer Intel cards
Date: Thu, 17 Apr 2003 18:44:37 -0400

Hi,

I've been trying to create the images of hard disks with GRUB and
found that on Linux it wants to write to the partition as a separate 
file. Which is not neccessary and just plain harmful in case if
I'm installing GRUB on a disk image. So I've made the attached a small
patch grub-0.91-hddimage.patch. The patch is made against a 
Caldera-patched version of 0.91 but it applies fine to 0.93 too.

The second patch grub-0.93-intelpci.patch is to include extra device IDs 
of the newer Intel network cards, I've copied them from the most recent
version of Etherboot.

I hope that these patches may be useful for the GRUB project.

-SB
diff -ur grub-0.91/grub/asmstub.c grub-0.91.old/grub/asmstub.c
--- grub-0.91/grub/asmstub.c    Thu Apr 17 18:15:50 2003
+++ grub-0.91.old/grub/asmstub.c        Thu Apr 17 18:12:33 2003
@@ -1048,6 +1048,30 @@
 #endif
 }
 
+/*
+ * Returns whether the disk is actually an image in a file.
+ * If it is, the workaround with write_to_partition
+ * becomes unneccessary
+ */
+int
+disk_is_image (int drive)
+{
+       struct stat st;
+       int res;
+
+       if (disks[drive].flags == -1) {
+               res = stat(device_map[drive], &st);
+       } else {
+               res = fstat(disks[drive].flags, &st);
+       }
+       if (res < 0)
+               return -1;
+       if (S_ISREG(st.st_mode))
+               return 1;
+       else
+               return 0;
+}
+
 /* Low-level disk I/O.  Our stubbed version just returns a file
    descriptor, not the actual geometry. */
 int
diff -ur grub-0.91/stage2/disk_io.c grub-0.91.old/stage2/disk_io.c
--- grub-0.91/stage2/disk_io.c  Thu Apr 17 18:15:51 2003
+++ grub-0.91.old/stage2/disk_io.c      Thu Apr 17 18:13:52 2003
@@ -25,6 +25,7 @@
 
 #ifdef GRUB_UTIL
 # include <device.h>
+int disk_is_image(int drive);
 #endif
 
 /* instrumentation variables */
@@ -330,7 +331,7 @@
 devwrite (int sector, int sector_count, char *buf)
 {
 #if defined(GRUB_UTIL) && defined(__linux__)
-  if (current_partition != 0xFFFFFF)
+  if (current_partition != 0xFFFFFF && !disk_is_image(current_drive))
     {
       /* If the grub shell is running under Linux and the user wants to
         embed a Stage 1.5 into a partition instead of a MBR, use system
diff -rc netboot.old/config.c netboot/config.c
*** netboot.old/config.c        Thu Apr 17 14:54:18 2003
--- netboot/config.c    Thu Apr 17 15:37:45 2003
***************
*** 122,127 ****
--- 122,137 ----
      "Intel EtherExpressPro100 ID1029", 0, 0, 0, 0},
    { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_ID1030,
      "Intel Corporation 82559 InBusiness 10/100", 0, 0, 0, 0},
+   { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_ID1031,
+     "Intel Pro/100 VE (LOM)", 0, 0, 0, 0},
+   { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_ID1038,
+     "Intel PRO/100 VM Network Connection", 0, 0, 0, 0},
+   { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_ID1039,
+     "Intel PRO100 VE 82562ET", 0, 0, 0, 0},
+   { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_ID103A,
+     "Intel EtherExpressPro100 InBusiness 10/100", 0, 0, 0, 0},
+   { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_ID103B,
+     "Intel PRO100 VE 82562ET", 0, 0, 0, 0},
    { PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_82562,
      "Intel EtherExpressPro100 82562EM", 0, 0, 0, 0},
  #endif
***************
*** 281,286 ****
--- 291,301 ----
    { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82559ER,   eepro100_probe },
    { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1029,    eepro100_probe },
    { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1030,    eepro100_probe },
+   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1031,    eepro100_probe },
+   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1038,    eepro100_probe },
+   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID1039,    eepro100_probe },
+   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID103A,    eepro100_probe },
+   { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_ID103B,    eepro100_probe },
    { PCI_VENDOR_ID_INTEL,    PCI_DEVICE_ID_INTEL_82562,     eepro100_probe },
  # endif /* INCLUDE_EEPRO100 */
  # ifdef       INCLUDE_EPIC100
diff -rc netboot.old/pci.h netboot/pci.h
*** netboot.old/pci.h   Thu Apr 17 14:54:18 2003
--- netboot/pci.h       Thu Apr 17 15:22:32 2003
***************
*** 129,134 ****
--- 129,139 ----
  #define PCI_DEVICE_ID_INTEL_82559ER   0x1209
  #define PCI_DEVICE_ID_INTEL_ID1029    0x1029
  #define PCI_DEVICE_ID_INTEL_ID1030    0x1030
+ #define PCI_DEVICE_ID_INTEL_ID1031    0x1031
+ #define PCI_DEVICE_ID_INTEL_ID1038    0x1038
+ #define PCI_DEVICE_ID_INTEL_ID1039    0x1039
+ #define PCI_DEVICE_ID_INTEL_ID103A    0x103a
+ #define PCI_DEVICE_ID_INTEL_ID103B    0x103b
  #define PCI_DEVICE_ID_INTEL_82562     0x2449
  #define PCI_VENDOR_ID_AMD             0x1022
  #define PCI_DEVICE_ID_AMD_LANCE               0x2000

reply via email to

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