2008-06-30 Pavel Roskin <proski@gnu.org>
* util/i386/pc/grub-setup.c (setup): Write install_dos_part and install_bsd_part immediately before core.img is embedded or modified on disk. This fixes core.img verification if core.img cannot be embedded.
This commit is contained in:
parent
3aefa85781
commit
56c7668bae
2 changed files with 23 additions and 9 deletions
|
@ -1,5 +1,10 @@
|
||||||
2008-06-30 Pavel Roskin <proski@gnu.org>
|
2008-06-30 Pavel Roskin <proski@gnu.org>
|
||||||
|
|
||||||
|
* util/i386/pc/grub-setup.c (setup): Write install_dos_part and
|
||||||
|
install_bsd_part immediately before core.img is embedded or
|
||||||
|
modified on disk. This fixes core.img verification if core.img
|
||||||
|
cannot be embedded.
|
||||||
|
|
||||||
* util/i386/pc/grub-setup.c (setup): Use core_path_dev, not
|
* util/i386/pc/grub-setup.c (setup): Use core_path_dev, not
|
||||||
core_path to calculate the blocklist.
|
core_path to calculate the blocklist.
|
||||||
Patch from Javier Martín <lordhabbit@gmail.com>
|
Patch from Javier Martín <lordhabbit@gmail.com>
|
||||||
|
|
|
@ -101,6 +101,7 @@ setup (const char *dir,
|
||||||
grub_uint16_t *boot_drive_check;
|
grub_uint16_t *boot_drive_check;
|
||||||
struct boot_blocklist *first_block, *block;
|
struct boot_blocklist *first_block, *block;
|
||||||
grub_int32_t *install_dos_part, *install_bsd_part;
|
grub_int32_t *install_dos_part, *install_bsd_part;
|
||||||
|
grub_int32_t dos_part, bsd_part;
|
||||||
char *tmp_img;
|
char *tmp_img;
|
||||||
int i;
|
int i;
|
||||||
grub_disk_addr_t first_sector;
|
grub_disk_addr_t first_sector;
|
||||||
|
@ -283,27 +284,29 @@ setup (const char *dir,
|
||||||
{
|
{
|
||||||
struct grub_pc_partition *pcdata =
|
struct grub_pc_partition *pcdata =
|
||||||
root_dev->disk->partition->data;
|
root_dev->disk->partition->data;
|
||||||
*install_dos_part
|
dos_part = pcdata->dos_part;
|
||||||
= grub_cpu_to_le32 (pcdata->dos_part);
|
bsd_part = pcdata->bsd_part;
|
||||||
*install_bsd_part
|
|
||||||
= grub_cpu_to_le32 (pcdata->bsd_part);
|
|
||||||
}
|
}
|
||||||
else if (strcmp (root_dev->disk->partition->partmap->name,
|
else if (strcmp (root_dev->disk->partition->partmap->name,
|
||||||
"gpt_partition_map") == 0)
|
"gpt_partition_map") == 0)
|
||||||
{
|
{
|
||||||
*install_dos_part = grub_cpu_to_le32 (root_dev->disk->partition->index);
|
dos_part = root_dev->disk->partition->index;
|
||||||
*install_bsd_part = grub_cpu_to_le32 (-1);
|
bsd_part = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
grub_util_error ("No PC style partitions found");
|
grub_util_error ("No PC style partitions found");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
*install_dos_part = *install_bsd_part = grub_cpu_to_le32 (-1);
|
dos_part = bsd_part = -1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dos_part = grub_le_to_cpu32 (*install_dos_part);
|
||||||
|
bsd_part = grub_le_to_cpu32 (*install_bsd_part);
|
||||||
}
|
}
|
||||||
|
|
||||||
grub_util_info ("dos partition is %d, bsd partition is %d",
|
grub_util_info ("dos partition is %d, bsd partition is %d",
|
||||||
grub_le_to_cpu32 (*install_dos_part),
|
dos_part, bsd_part);
|
||||||
grub_le_to_cpu32 (*install_bsd_part));
|
|
||||||
|
|
||||||
/* If the destination device can have partitions and it is the MBR,
|
/* If the destination device can have partitions and it is the MBR,
|
||||||
try to embed the core image into after the MBR. */
|
try to embed the core image into after the MBR. */
|
||||||
|
@ -316,6 +319,9 @@ setup (const char *dir,
|
||||||
{
|
{
|
||||||
grub_util_info ("will embed the core image at sector 0x%llx", embed_region.start);
|
grub_util_info ("will embed the core image at sector 0x%llx", embed_region.start);
|
||||||
|
|
||||||
|
*install_dos_part = grub_cpu_to_le32 (dos_part);
|
||||||
|
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
|
||||||
|
|
||||||
/* The first blocklist contains the whole sectors. */
|
/* The first blocklist contains the whole sectors. */
|
||||||
first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
|
first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
|
||||||
first_block->len = grub_cpu_to_le16 (core_sectors - 1);
|
first_block->len = grub_cpu_to_le16 (core_sectors - 1);
|
||||||
|
@ -485,6 +491,9 @@ setup (const char *dir,
|
||||||
the boot device. */
|
the boot device. */
|
||||||
*root_drive = 0xFF;
|
*root_drive = 0xFF;
|
||||||
|
|
||||||
|
*install_dos_part = grub_cpu_to_le32 (dos_part);
|
||||||
|
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
|
||||||
|
|
||||||
/* Write the first two sectors of the core image onto the disk. */
|
/* Write the first two sectors of the core image onto the disk. */
|
||||||
grub_util_info ("opening the core image `%s'", core_path);
|
grub_util_info ("opening the core image `%s'", core_path);
|
||||||
fp = fopen (core_path, "r+b");
|
fp = fopen (core_path, "r+b");
|
||||||
|
|
Loading…
Reference in a new issue