]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
New partition naming style in grub-probe for Linux and NetBSD.
authorGrégoire Sutre <gregoire.sutre@gmail.com>
Sun, 13 Jun 2010 00:36:39 +0000 (02:36 +0200)
committerGrégoire Sutre <gregoire.sutre@gmail.com>
Sun, 13 Jun 2010 00:36:39 +0000 (02:36 +0200)
ChangeLog
kern/emu/hostdisk.c
util/grub-install.in

index 15856dc5749647abeef2dc6e8d13d32cb018df4b..766a5053f0fc123ab8952b6506af968b00879163 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-06-13  Grégoire Sutre  <gregoire.sutre@gmail.com>
+
+       * kern/emu/hostdisk.c (grub_util_biosdisk_get_grub_dev): Use the
+       new partition naming style.
+       * util/grub-install.in: Adapt sed subtitutions in grub-probe calls.
+
 2010-06-12  BVK Chaitanya  <bvk.groups@gmail.com>
 
        Add "-o grub.iso" like cmdline options support.
index 47389195cfd0de5b80f3b0447c78347059842d4e..bc37e9949e3e4add9ee1229b66a8a9724347fbf3 100644 (file)
@@ -992,6 +992,11 @@ grub_util_biosdisk_fini (void)
   grub_disk_dev_unregister (&grub_util_biosdisk_dev);
 }
 
+/*
+ * Note: we do not use the new partition naming scheme as dos_part does not
+ * necessarily correspond to an msdos partition.  See e.g. the FreeBSD code
+ * in function grub_util_biosdisk_get_grub_dev.
+ */
 static char *
 make_device_name (int drive, int dos_part, int bsd_part)
 {
@@ -1400,11 +1405,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
      For NetBSD, proceed as for Linux, except that the start sector is
      obtained from the disk label.  */
   {
-    char *name;
+    char *name, *partname;
     grub_disk_t disk;
     grub_disk_addr_t start;
-    int dos_part = -1;
-    int bsd_part = -1;
     auto int find_partition (grub_disk_t dsk,
                             const grub_partition_t partition);
 
@@ -1419,17 +1422,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
 
        if (start == part_start)
          {
-           if (partition->parent)
-             {
-               dos_part = partition->parent->number;
-               bsd_part = partition->number;
-             }
-           else
-             {
-               dos_part = partition->number;
-               bsd_part = -1;
-             }
-
+           partname = grub_partition_get_name (partition);
            return 1;
          }
 
@@ -1465,6 +1458,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
     if (! disk)
       return 0;
 
+    partname = NULL;
     grub_partition_iterate (disk, find_partition);
     if (grub_errno != GRUB_ERR_NONE)
       {
@@ -1472,7 +1466,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
        return 0;
       }
 
-    if (dos_part < 0)
+    if (partname == NULL)
       {
        grub_disk_close (disk);
        grub_error (GRUB_ERR_BAD_DEVICE,
@@ -1480,7 +1474,9 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
        return 0;
       }
 
-    return make_device_name (drive, dos_part, bsd_part);
+    name = grub_xasprintf ("%s,%s", disk->name, partname);
+    free (partname);
+    return name;
   }
 
 #elif defined(__GNU__)
@@ -1525,7 +1521,7 @@ grub_util_biosdisk_get_grub_dev (const char *os_dev)
         for (p = os_dev + 5; *p; ++p)
           if (grub_isdigit(*p))
             {
-              p = strchr (p, 's');
+              p = strchr (p, 's');    /* msdos or apple (or ... ?) partition map */
               if (p)
                 {
                   p++;
index e580ac81926e637d9853ee80c41a567b9a0da1f2..c7e087dd0f0969ce5ebed7f1ff38e5112afff46b 100644 (file)
@@ -356,12 +356,12 @@ if [ "x${devabstraction_module}" = "x" ] ; then
       else
         install_drive="`$grub_probe --target=drive --device ${install_device}`" || exit 1
       fi
-      install_drive="`echo ${install_drive} | sed -e s/,[0-9]*[a-z]*//g`"
+      install_drive="`echo ${install_drive} | sed -e s/,[a-z0-9,]*//g`"
     fi
     grub_drive="`$grub_probe --target=drive --device ${grub_device}`" || exit 1
 
     # Strip partition number
-    grub_drive="`echo ${grub_drive} | sed -e s/,[0-9]*[a-z]*//g`"
+    grub_drive="`echo ${grub_drive} | sed -e s/,[a-z0-9,]*//g`"
     if [ "$disk_module" = ata ] ; then
         # generic method (used on coreboot and ata mod)
         uuid="`$grub_probe --target=fs_uuid --device ${grub_device}`"