]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Fix i386-pc prefix handling with nested partitions (Debian bug
authorColin Watson <cjwatson@ubuntu.com>
Thu, 17 Jun 2010 11:15:37 +0000 (12:15 +0100)
committerColin Watson <cjwatson@ubuntu.com>
Thu, 17 Jun 2010 11:15:37 +0000 (12:15 +0100)
#585068).  Note that the case where the core image is booted using
multiboot and relocated from its original location still requires
more work.
* kern/i386/pc/init.c (make_install_device): If the prefix starts
with "(,", fill the boot drive in between those two characters, but
expect that a full partition specification including partition map
names will follow.
* util/i386/pc/grub-setup.c (setup): Unless an explicit prefix was
specified, write a prefix without the drive name but including a
full partition specification.

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

index 88e1e43d6e4e3d6cb5efe814cca1fbacbc35e6c5..e2f240f40fc4e3e95c73350b75c2a4143da7e649 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2010-06-17  Colin Watson  <cjwatson@ubuntu.com>
+
+       Fix i386-pc prefix handling with nested partitions (Debian bug
+       #585068).  Note that the case where the core image is booted using
+       multiboot and relocated from its original location still requires
+       more work.
+
+       * kern/i386/pc/init.c (make_install_device): If the prefix starts
+       with "(,", fill the boot drive in between those two characters, but
+       expect that a full partition specification including partition map
+       names will follow.
+       * util/i386/pc/grub-setup.c (setup): Unless an explicit prefix was
+       specified, write a prefix without the drive name but including a
+       full partition specification.
+
 2010-06-16  Colin Watson  <cjwatson@ubuntu.com>
 
        * util/grub-mkconfig.in: Ignore non-option arguments, for
index d81b1e117b9a63ed9674b9592fd9e65ede990d02..8cbc757b2182958a77877645757cbe2b93a97ba2 100644 (file)
@@ -83,6 +83,14 @@ make_install_device (void)
       grub_snprintf (ptr, sizeof (dev) - (ptr - dev), ")%s", grub_prefix);
       grub_strcpy (grub_prefix, dev);
     }
+  else if (grub_prefix[1] == ',' || grub_prefix[1] == ')')
+    {
+      /* We have a prefix, but still need to fill in the boot drive.  */
+      grub_snprintf (dev, sizeof (dev),
+                    "(%cd%u%s", (grub_boot_drive & 0x80) ? 'h' : 'f',
+                    grub_boot_drive & 0x7f, grub_prefix + 1);
+      grub_strcpy (grub_prefix, dev);
+    }
 
   return grub_prefix;
 }
index f0baf1c897cdd26b2375484f537c66e1995b0059..454fba9fa212b80e6a9c847a06e76514b5c4a100 100644 (file)
@@ -99,6 +99,7 @@ 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 *tmp_img;
   int i;
   grub_disk_addr_t first_sector;
@@ -230,6 +231,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);
 
   /* Open the root device and the destination device.  */
   root_dev = grub_device_open (root);
@@ -305,6 +308,18 @@ setup (const char *dir,
              dos_part = root_dev->disk->partition->number;
              bsd_part = -1;
            }
+
+         if (prefix[0] != '(')
+           {
+             char *root_part_name, *new_prefix;
+
+             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);
+             free (root_part_name);
+           }
        }
       else
        dos_part = bsd_part = -1;