]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/i386/pc/grub-setup.c (setup): Rename prefix to
authorColin Watson <cjwatson@ubuntu.com>
Mon, 5 Jul 2010 00:09:00 +0000 (01:09 +0100)
committerColin Watson <cjwatson@ubuntu.com>
Mon, 5 Jul 2010 00:09:00 +0000 (01:09 +0100)
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.

ChangeLog
util/i386/pc/grub-setup.c

index 31020644eebaf16a3b494ecdad4c6ea0949f963a..9162f2bdd15608985240c45096ccb2a824f36224 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 3fe7d56225822f51a2c0f38707b399fb1e1f361d..8b2f52bb4a7d4aad2956fbdf699c98da7bd01693 100644 (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);