* util/i386/pc/grub-setup.c (setup): Rename prefix to

install_prefix, in line with install_dos_part and install_bsd_part.
Add new prefix variable, which is copied to install_prefix after
comparing core.img in memory with the one read from disk in the
no-embedding case, and use that rather than overwriting
install_prefix immediately when installing to a partition.
Fixes Debian bug #586621; based on patches by Matt Kraai and M. Vefa
Bicakci.
This commit is contained in:
Colin Watson 2010-07-05 01:09:00 +01:00
parent 57ebd41ef1
commit 38d8f4f3f7
2 changed files with 23 additions and 8 deletions

View File

@ -1,3 +1,14 @@
2010-07-05 Colin Watson <cjwatson@ubuntu.com>
* util/i386/pc/grub-setup.c (setup): Rename prefix to
install_prefix, in line with install_dos_part and install_bsd_part.
Add new prefix variable, which is copied to install_prefix after
comparing core.img in memory with the one read from disk in the
no-embedding case, and use that rather than overwriting
install_prefix immediately when installing to a partition.
Fixes Debian bug #586621; based on patches by Matt Kraai and M. Vefa
Bicakci.
2010-07-04 Grégoire Sutre <gregoire.sutre@gmail.com>
* configure.ac: Avoid == in test command, it's not portable.

View File

@ -102,7 +102,8 @@ setup (const char *dir,
struct grub_boot_blocklist *first_block, *block;
grub_int32_t *install_dos_part, *install_bsd_part;
grub_int32_t dos_part, bsd_part;
char *prefix;
char *install_prefix;
char *prefix = NULL;
char *tmp_img;
int i;
grub_disk_addr_t first_sector;
@ -234,8 +235,8 @@ setup (const char *dir,
+ GRUB_KERNEL_MACHINE_INSTALL_DOS_PART);
install_bsd_part = (grub_int32_t *) (core_img + GRUB_DISK_SECTOR_SIZE
+ GRUB_KERNEL_MACHINE_INSTALL_BSD_PART);
prefix = (char *) (core_img + GRUB_DISK_SECTOR_SIZE +
GRUB_KERNEL_MACHINE_PREFIX);
install_prefix = (char *) (core_img + GRUB_DISK_SECTOR_SIZE +
GRUB_KERNEL_MACHINE_PREFIX);
/* Open the root device and the destination device. */
root_dev = grub_device_open (root);
@ -312,15 +313,13 @@ setup (const char *dir,
bsd_part = -1;
}
if (prefix[0] != '(')
if (install_prefix[0] != '(')
{
char *root_part_name, *new_prefix;
char *root_part_name;
root_part_name =
grub_partition_get_name (root_dev->disk->partition);
new_prefix = xasprintf ("(,%s)%s", root_part_name, prefix);
strcpy (prefix, new_prefix);
free (new_prefix);
prefix = xasprintf ("(,%s)%s", root_part_name, install_prefix);
free (root_part_name);
}
}
@ -411,6 +410,8 @@ setup (const char *dir,
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* The first blocklist contains the whole sectors. */
first_block->start = grub_cpu_to_le64 (embed_region.start + 1);
@ -571,6 +572,8 @@ unable_to_embed:
*install_dos_part = grub_cpu_to_le32 (dos_part);
*install_bsd_part = grub_cpu_to_le32 (bsd_part);
if (prefix)
strcpy (install_prefix, prefix);
/* Write the first two sectors of the core image onto the disk. */
grub_util_info ("opening the core image `%s'", core_path);
@ -590,6 +593,7 @@ unable_to_embed:
/* Sync is a Good Thing. */
sync ();
free (prefix);
free (core_path);
free (core_img);
free (boot_img);