+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.
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;
+ 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);
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);
}
}
*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);
*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);
/* Sync is a Good Thing. */
sync ();
+ free (prefix);
free (core_path);
free (core_img);
free (boot_img);