]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* util/grub-install.in: Add GPT PReP support.
authorPaulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Mon, 23 Sep 2013 20:42:32 +0000 (17:42 -0300)
committerPaulo Flabiano Smorigo <pfsmorigo@br.ibm.com>
Mon, 23 Sep 2013 20:42:32 +0000 (17:42 -0300)
        * util/grub-probe.c (probe): Support GPT partition type.
        (main): Support -t gpt_parttype.

ChangeLog
util/grub-install.in
util/grub-probe.c

index 9181ee2b7ab5f4cbe940717f4cd1b6e99c8527eb..505e2234c5b5fb7e9c566b84040b328998f4fcb3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-09-23  Paulo Flabiano Smorigo  <pfsmorigo@br.ibm.com>
+
+       * util/grub-install.in: Add GPT PReP support.
+       * util/grub-probe.c (probe): Support GPT partition type.
+       (main): Support -t gpt_parttype.
+
 2013-09-23  Aleš Nesrsta  <starous@volny.cz>
 
        * grub-core/bus/usb/ehci.c: SMI disabled in all cases
index acd516f2c2089cc0d313f301e4dead5f99e5f9b4..ce8f8401955eab65e8e810128340754c264130b0 100644 (file)
@@ -686,10 +686,12 @@ elif [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "i386-ieee1275" ]
 
     # If a install device is defined, copy the core.elf to PReP partition.
     if [ "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" = "powerpc-ieee1275" ] && [ -n "${install_device}" ]; then
-        if [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t msdos_parttype)" != "41" ]; then
-              gettext "The chosen partition is not a PReP partition." 1>&2
-              echo 1>&2
-              exit 1
+
+        if [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t msdos_parttype)" != "41" ] \
+            && [ "$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t gpt_parttype)" != "9e1a2d38-c612-4316-aa26-8b49521e5a8b" ]; then
+            gettext "The chosen partition is not a PReP partition." 1>&2
+            echo 1>&2
+            exit 1
         fi
 
         if [ "$(file -s -b -L "${install_device}" | awk '{ print $1 }')" = ELF ] || [ x$("${grub_probe}" -m "${device_map}" -d "${install_device}" -t zero_check) = xtrue ]; then
index 0978e0a42fbe92e8b083092e159ecab4699f46ea..1f561962aa4d94dbcdfe0392daa2bb5afd34fb13 100644 (file)
@@ -27,6 +27,7 @@
 #include <grub/fs.h>
 #include <grub/partition.h>
 #include <grub/msdos_partition.h>
+#include <grub/gpt_partition.h>
 #include <grub/emu/hostdisk.h>
 #include <grub/emu/getroot.h>
 #include <grub/term.h>
@@ -67,6 +68,7 @@ enum {
   PRINT_ARC_HINT,
   PRINT_COMPATIBILITY_HINT,
   PRINT_MSDOS_PARTTYPE,
+  PRINT_GPT_PARTTYPE,
   PRINT_ZERO_CHECK,
   PRINT_DISK
 };
@@ -725,6 +727,39 @@ probe (const char *path, char **device_names, char delim)
          grub_device_close (dev);
          continue;
        }
+
+      if (print == PRINT_GPT_PARTTYPE)
+       {
+          if (dev->disk->partition
+             && strcmp (dev->disk->partition->partmap->name, "gpt") == 0)
+            {
+              struct grub_gpt_partentry gptdata;
+              grub_partition_t p = dev->disk->partition;
+              dev->disk->partition = dev->disk->partition->parent;
+
+              if (grub_disk_read (dev->disk, p->offset, p->index,
+                                  sizeof (gptdata), &gptdata) == 0)
+                {
+                  grub_gpt_part_type_t gpttype;
+                  gpttype.data1 = grub_le_to_cpu32 (gptdata.type.data1);
+                  gpttype.data2 = grub_le_to_cpu16 (gptdata.type.data2);
+                  gpttype.data3 = grub_le_to_cpu16 (gptdata.type.data3);
+                  grub_memcpy (gpttype.data4, gptdata.type.data4, 8);
+
+                  grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+                               gpttype.data1, gpttype.data2,
+                               gpttype.data3, gpttype.data4[0], 
+                               gpttype.data4[1], gpttype.data4[2],
+                               gpttype.data4[3], gpttype.data4[4],
+                               gpttype.data4[5], gpttype.data4[6],
+                               gpttype.data4[7]);
+                }
+              dev->disk->partition = p;
+            }
+          putchar (delim);
+          grub_device_close (dev);
+          continue;
+        }
     }
 
  end:
@@ -805,6 +840,8 @@ argp_parser (int key, char *arg, struct argp_state *state)
        print = PRINT_CRYPTODISK_UUID;
       else if (!strcmp (arg, "msdos_parttype"))
        print = PRINT_MSDOS_PARTTYPE;
+      else if (!strcmp (arg, "gpt_parttype"))
+       print = PRINT_GPT_PARTTYPE;
       else if (!strcmp (arg, "hints_string"))
        print = PRINT_HINT_STR;
       else if (!strcmp (arg, "bios_hints"))