From 80d0f93b30a1c17b93713130b5e5d999ba335b97 Mon Sep 17 00:00:00 2001 From: okuji Date: Fri, 5 Jul 2002 22:15:57 +0000 Subject: [PATCH] 2002-07-06 Yoshinori K. Okuji * stage2/shared.h (boot_part_offset): Removed. * stage2/disk_io.c (set_bootdev): Copy the partition information here. Now this function can call rawread, so it can fail. (boot_part_offset): Removed. * stage2/builtins.c (boot_func): Don't copy the partition information here. (real_root_func): Check ERRNUM after calling set_bootdev. --- ChangeLog | 12 ++++++++++++ stage2/builtins.c | 45 +++++++-------------------------------------- stage2/disk_io.c | 30 ++++++++++++++++++++++++++---- stage2/shared.h | 1 - 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/ChangeLog b/ChangeLog index eef6abfc0..d7e6df037 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2002-07-06 Yoshinori K. Okuji + + * stage2/shared.h (boot_part_offset): Removed. + + * stage2/disk_io.c (set_bootdev): Copy the partition information + here. Now this function can call rawread, so it can fail. + (boot_part_offset): Removed. + + * stage2/builtins.c (boot_func): Don't copy the partition + information here. + (real_root_func): Check ERRNUM after calling set_bootdev. + 2002-07-04 Yoshinori K. Okuji * docs/grub.texi (Reporting bugs): Use the group name (i.e. diff --git a/stage2/builtins.c b/stage2/builtins.c index 2d916649d..e3ed8ba6a 100644 --- a/stage2/builtins.c +++ b/stage2/builtins.c @@ -288,43 +288,6 @@ boot_func (char *arg, int flags) gateA20 (0); boot_drive = saved_drive; - - /* Copy the boot partition information to 0x7be-0x7fd, if - BOOT_DRIVE is a hard disk drive and the address of the boot - partition entry is set. */ - if ((boot_drive & 0x80) && boot_part_addr) - { - char *dst, *src; - int i; - - if (debug) - grub_printf ("reading the offset 0x%x in the drive 0x%x\n", - boot_drive, boot_part_offset); - - /* Read the MBR here, because it might be modified - after opening the partition. */ - if (! rawread (boot_drive, boot_part_offset, - 0, SECTOR_SIZE, (char *) SCRATCHADDR)) - { - /* This should never happen. */ - return 0; - } - - /* Need only the partition table. - XXX: We cannot use grub_memmove because BOOT_PART_TABLE - (0x07be) is less than 0x1000. */ - dst = (char *) BOOT_PART_TABLE; - src = (char *) SCRATCHADDR + BOOTSEC_PART_OFFSET; - while (dst < (char *) BOOT_PART_TABLE + BOOTSEC_PART_LENGTH) - *dst++ = *src++; - - /* Set the active flag of the booted partition. */ - for (i = 0; i < 4; i++) - PC_SLICE_FLAG (BOOT_PART_TABLE, i) = 0; - - *((unsigned char *) boot_part_addr) = PC_SLICE_FLAG_BOOTABLE; - } - chain_stage1 (0, BOOTSEC_LOCATION, boot_part_addr); break; @@ -3133,7 +3096,11 @@ real_root_func (char *arg, int attempt_mount) /* This is necessary, because the location of a partition table must be set appropriately. */ if (open_partition ()) + { set_bootdev (0); + if (errnum) + return 1; + } } /* Clear ERRNUM. */ @@ -3148,7 +3115,9 @@ real_root_func (char *arg, int attempt_mount) safe_parse_maxint (&biasptr, &hdbias); errnum = 0; bootdev = set_bootdev (hdbias); - + if (errnum) + return 1; + /* Print the type of the filesystem. */ print_fsys_type (); } diff --git a/stage2/disk_io.c b/stage2/disk_io.c index 8fe314f22..920eb7bf8 100644 --- a/stage2/disk_io.c +++ b/stage2/disk_io.c @@ -90,7 +90,6 @@ unsigned long current_partition; /* The register ESI should contain the address of the partition to be used for loading a chain-loader when chain-loading the loader. */ unsigned long boot_part_addr = 0; -unsigned long boot_part_offset; #endif /* @@ -1072,9 +1071,32 @@ set_bootdev (int hdbias) { int i, j; - /* Save the boot partition for chain-loading. */ - boot_part_offset = cur_part_offset; - boot_part_addr = cur_part_addr; + /* Copy the boot partition information to 0x7be-0x7fd for chain-loading. */ + if ((saved_drive & 0x80) && cur_part_addr) + { + if (rawread (saved_drive, cur_part_offset, + 0, SECTOR_SIZE, (char *) SCRATCHADDR)) + { + char *dst, *src; + + /* Need only the partition table. + XXX: We cannot use grub_memmove because BOOT_PART_TABLE + (0x07be) is less than 0x1000. */ + dst = (char *) BOOT_PART_TABLE; + src = (char *) SCRATCHADDR + BOOTSEC_PART_OFFSET; + while (dst < (char *) BOOT_PART_TABLE + BOOTSEC_PART_LENGTH) + *dst++ = *src++; + + /* Set the active flag of the booted partition. */ + for (i = 0; i < 4; i++) + PC_SLICE_FLAG (BOOT_PART_TABLE, i) = 0; + + *((unsigned char *) cur_part_addr) = PC_SLICE_FLAG_BOOTABLE; + boot_part_addr = cur_part_addr; + } + else + return 0; + } /* * Set BSD boot device. diff --git a/stage2/shared.h b/stage2/shared.h index 539abbe93..cf51549e2 100644 --- a/stage2/shared.h +++ b/stage2/shared.h @@ -545,7 +545,6 @@ extern unsigned long boot_drive; extern unsigned long install_second_sector; extern struct apm_info apm_bios_info; extern unsigned long boot_part_addr; -extern unsigned long boot_part_offset; extern int saved_entryno; extern unsigned char force_lba; extern char version_string[];