+2007-09-03 Yoshinori K. Okuji <okuji@enbug.org>
+
+ Do not use devices at boot in chainloading.
+
+ * loader/i386/pc/chainloader.c (boot_drive): New variable.
+ (boot_part_addr): Likewise.
+ (grub_chainloader_boot): Simply call grub_chainloader_real_boot
+ with BOOT_DRIVE and BOOT_PART_ADDR.
+ (grub_chainloader_cmd): Set BOOT_DRIVE and BOOT_PART_ADDR.
+ Reported by Hitoshi Ozeki <h-ozeki@ck2.so-net.ne.jp>.
+
2007-08-29 Robert Millan <rmh@aybabtu.com>
Patch from Simon Peter <dn.tlp@gmx.net>:
#include <grub/dl.h>
static grub_dl_t my_mod;
+static int boot_drive;
+static void *boot_part_addr;
static grub_err_t
grub_chainloader_boot (void)
{
- grub_device_t dev;
- int drive = -1;
- void *part_addr = 0;
-
- /* Open the root device. */
- dev = grub_device_open (0);
- if (dev)
- {
- grub_disk_t disk = dev->disk;
-
- if (disk)
- {
- grub_partition_t p = disk->partition;
-
- /* In i386-pc, the id is equal to the BIOS drive number. */
- drive = (int) disk->id;
-
- if (p)
- {
- grub_disk_read (disk, p->offset, 446, 64,
- (char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
-
- /* Ignore errors. Perhaps it's not fatal. */
- part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
- + (p->index << 4));
- }
- }
-
- grub_device_close (dev);
- }
-
- grub_chainloader_real_boot (drive, part_addr);
+ grub_chainloader_real_boot (boot_drive, boot_part_addr);
/* Never reach here. */
return GRUB_ERR_NONE;
{
grub_file_t file = 0;
grub_uint16_t signature;
+ grub_device_t dev;
+ int drive = -1;
+ void *part_addr = 0;
grub_dl_ref (my_mod);
}
grub_file_close (file);
+
+ /* Obtain the partition table from the root device. */
+ dev = grub_device_open (0);
+ if (dev)
+ {
+ grub_disk_t disk = dev->disk;
+
+ if (disk)
+ {
+ grub_partition_t p = disk->partition;
+
+ /* In i386-pc, the id is equal to the BIOS drive number. */
+ drive = (int) disk->id;
+
+ if (p)
+ {
+ grub_disk_read (disk, p->offset, 446, 64,
+ (char *) GRUB_MEMORY_MACHINE_PART_TABLE_ADDR);
+ part_addr = (void *) (GRUB_MEMORY_MACHINE_PART_TABLE_ADDR
+ + (p->index << 4));
+ }
+ }
+
+ grub_device_close (dev);
+ }
+
+ /* Ignore errors. Perhaps it's not fatal. */
+ grub_errno = GRUB_ERR_NONE;
+
+ boot_drive = drive;
+ boot_part_addr = part_addr;
+
grub_loader_set (grub_chainloader_boot, grub_chainloader_unload, 1);
return;