grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support
@ 2017-02-27  0:20 Nicholas Vinson
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue Nicholas Vinson
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Nicholas Vinson @ 2017-02-27  0:20 UTC (permalink / raw)
  To: skenton, grub-devel

Changes from Patch v2:
    - Added flex-2.6.3 compatibility patch

    - Fixed a GPT partition read error

    - Added Steve Kenton's patch

    - Changed struct grub_part_gpt_type name to struct
      grub_part_gpt_part_guid

    - Changed grub_part_gpt_type_t typedef name to grub_part_gpt_guid_t

    - Added sprint_gpt_guid to Steve Kenton's patch

    - Updated v1 and Steve Kenton's patch to use similar methods when
      reading partition GUIDs.

Changes from Patch v1:
    - Added GRUB_ENABLE_LINUX_PARTUUID variable description to grub.texi

    - Removed added gpt_part_guid copy logic from
      grub_gpt_partition_map_iterate()

    - Removed added NT disk signature copy logic from
      grub_partition_msdos_iterate()

    - Removed modifications to partition number increment logic

    - Removed added guid union definition.

    - Added GRUB_ENABLE_LINUX_PARTUUID to grub-mkconfig.in export list

    - Moved PRINT_GPT_PARTTYPE printing logic to print_gpt_guid()
      function in grub-probe.c

    - Updated PRINT_GPT_PARTTYPE case to call print_gpt_guid() function
      in grub-probe.c.

    - Created probe_partuuid() function in grub-probe.c

    - Updated print == PRINT_PARTUUID check logic in probe() to call
      probe_partuuid().

    - Updated UUID logic in 10_linux.in to enable root=PARTUUID feature
      only if GRUB_DISABLE_LINUX_UUID is not set to true,
      and GRUB_DEVICE_PARTUUID is not empty, GRUB_ENABLE_LINUX_PARTUUID
      is set to true.

Hello,

This is a request to add PARTUUID detection support grub-probe for MBR
and GPT partition schemes.  The Linux kernel supports mounting the root
filesystem by Linux device name or by the Partition [GU]UID.  GRUB's
mkconfig, however, currently only supports specifying the rootfs in the
kernel command-line by Linux device name unless an initramfs is also
present.  When an initramfs is present GRUB's mkconfig will set the
kernel's root parameter value to either the Linux device name or to the
filesystem [GU]UID.

Therefore, the only way to protect a Linux system from failing to boot
when its Linux storage device names change is to either manually edit
grub.cfg or /etc/default/grub and append root=PARTUUID=xxx to the
command-line or create an initramfs that understands how to mount
devices by filesystem [G]UID and let grub-mkconfig pass the filesystem
[GU]UID to the initramfs.

The goal of this patch set is to enable root=PARTUUID=xxx support in
grub-mkconfig, so that users don't have to manually edit
/etc/default/grub or grub.cfg, or create an initramfs for the sole
purpose of having a robust bootloader configuration for Linux.

Thanks,
Nicholas Vinson

Nicholas Vinson (4):
  Fix flex-2.6.3 incompatbility issue
  Add PARTUUID detection support to grub-probe
  Update grub script template files
  Harmonize patches

Steve Kenton (1):
  Support both EFI and NT Disk Signature for passing to kernel as
    root=PARTUUID=$val

 docs/grub.texi               | 13 +++++++
 grub-core/commands/probe.c   | 78 ++++++++++++++++++++++++++++++++++++++++++
 grub-core/disk/ldm.c         |  2 +-
 grub-core/partmap/gpt.c      |  4 +--
 grub-core/script/yylex.l     | 22 +++++++++---
 include/grub/gpt_partition.h |  8 ++---
 util/grub-install.c          |  2 +-
 util/grub-mkconfig.in        |  3 ++
 util/grub-probe.c            | 81 ++++++++++++++++++++++++++++++++++++--------
 util/grub.d/10_linux.in      | 13 +++++--
 10 files changed, 197 insertions(+), 29 deletions(-)

-- 
2.12.0



^ permalink raw reply	[flat|nested] 14+ messages in thread

* [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue
  2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
@ 2017-02-27  0:20 ` Nicholas Vinson
  2017-02-27  0:28   ` Vladimir 'phcoder' Serbinenko
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 2/5] Add PARTUUID detection support to grub-probe Nicholas Vinson
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2017-02-27  0:20 UTC (permalink / raw)
  To: skenton, grub-devel

---
 grub-core/script/yylex.l | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
index 95b219170..3917904b4 100644
--- a/grub-core/script/yylex.l
+++ b/grub-core/script/yylex.l
@@ -31,10 +31,6 @@
 #pragma GCC diagnostic ignored "-Wunused-function"
 #pragma GCC diagnostic ignored "-Wsign-compare"
 
-#define yyalloc(size, scanner)   (grub_malloc((size)))
-#define yyfree(ptr, scanner)   (grub_free((ptr)))
-#define yyrealloc(ptr, size, scanner) (grub_realloc((ptr), (size)))
-
 /* 
  * As we don't have access to yyscanner, we cannot do much except to
  * print the fatal error.
@@ -327,6 +323,24 @@ POS_MULTILINE   {WORD}?\\\n
                 }
 %%
 
+void *
+yyalloc(yy_size_t size, yyscan_t yyscanner)
+{
+  return grub_malloc(size);
+}
+
+void
+yyfree(void *ptr, yyscan_t yyscanner)
+{
+  return grub_free(ptr);
+}
+
+void *
+yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
+{
+  return grub_realloc(ptr, size);
+}
+
 int
 yywrap (yyscan_t yyscanner)
 {
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [GRUB PARTUUID PATCH V3 2/5] Add PARTUUID detection support to grub-probe
  2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue Nicholas Vinson
@ 2017-02-27  0:20 ` Nicholas Vinson
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 3/5] Update grub script template files Nicholas Vinson
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Nicholas Vinson @ 2017-02-27  0:20 UTC (permalink / raw)
  To: skenton, grub-devel

Add PARTUUID detection support grub-probe for MBR and GPT partition
schemes.  The Linux kernel supports mounting the root filesystem by
Linux device name or by the Partition [GU]UID.  GRUB's mkconfig,
however, currently only supports specifing the rootfs in the kernel
command-line by Linux device name unless an initramfs is also present.
When an initramfs is present GRUB's mkconfig will set the kernel's root
parameter value to either the Linux device name or to the filesystem
[GU]UID.

Therefore, the only way to protect a Linux system from failing to boot
when its Linux storage device names change is to either manually edit
grub.cfg or /etc/default/grub and append root=PARTUUID=xxx to the
command-line or create an initramfs that understands how to mount
devices by filesystem [G]UID and let grub-mkconfig pass the filesystem
[GU]UID to the initramfs.

The goal of this patch set is to enable root=PARTUUID=xxx support in
grub-mkconfig, so that users don't have to manually edit
/etc/default/grub or grub.cfg, or create an initramfs for the sole
purpose of having a robust bootloader configuration for Linux.
---
 util/grub-probe.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 60 insertions(+)

diff --git a/util/grub-probe.c b/util/grub-probe.c
index 8ac527d2f..81f550e0d 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -28,6 +28,7 @@
 #include <grub/partition.h>
 #include <grub/msdos_partition.h>
 #include <grub/gpt_partition.h>
+#include <grub/i386/pc/boot.h>
 #include <grub/emu/hostdisk.h>
 #include <grub/emu/getroot.h>
 #include <grub/term.h>
@@ -62,6 +63,7 @@ enum {
   PRINT_DRIVE,
   PRINT_DEVICE,
   PRINT_PARTMAP,
+  PRINT_PARTUUID,
   PRINT_ABSTRACTION,
   PRINT_CRYPTODISK_UUID,
   PRINT_HINT_STR,
@@ -85,6 +87,7 @@ static const char *targets[] =
     [PRINT_DRIVE]              = "drive",
     [PRINT_DEVICE]             = "device",
     [PRINT_PARTMAP]            = "partmap",
+    [PRINT_PARTUUID]           = "partuuid",
     [PRINT_ABSTRACTION]        = "abstraction",
     [PRINT_CRYPTODISK_UUID]    = "cryptodisk_uuid",
     [PRINT_HINT_STR]           = "hints_string",
@@ -168,6 +171,57 @@ probe_partmap (grub_disk_t disk, char delim)
 }
 
 static void
+probe_partuuid (grub_disk_t disk, char delim)
+{
+  /*
+   * Nested partitions not supported for now.
+   * Non-nested partitions must have disk->partition->parent == NULL
+   */
+  if (disk->partition && disk->partition->parent == NULL)
+    {
+      if (strcmp(disk->partition->partmap->name, "msdos") == 0)
+	{
+	    /*
+	     * The partition GUID for MSDOS is the partition number (starting
+	     * with 1) prepended with the NT disk signature.
+	     */
+            grub_uint32_t nt_disk_sig;
+	    grub_partition_t p = disk->partition;
+	    disk->partition = p->parent;
+
+	    if (grub_disk_read (disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+				sizeof(nt_disk_sig), &nt_disk_sig) == 0)
+	      {
+		grub_printf ("%08x-%02x",
+			     grub_le_to_cpu32(nt_disk_sig), 1 + p->number);
+	      }
+	    disk->partition = p;
+	}
+      else if (strcmp(disk->partition->partmap->name, "gpt") == 0)
+	{
+	  grub_partition_t p = disk->partition;
+	  struct grub_gpt_partentry gptdata;
+
+	  disk->partition = p->parent;
+
+	  if (grub_disk_read (disk, p->offset, p->index,
+			      sizeof(gptdata), &gptdata) == 0)
+	    {
+	      grub_printf ("%02x%02x%02x%02x-%02x%02x-%02x%02x"
+			   "-%02x%02x-%02x%02x%02x%02x%02x%02x",
+			   gptdata.guid[3], gptdata.guid[2], gptdata.guid[1],
+			   gptdata.guid[0], gptdata.guid[5], gptdata.guid[4],
+			   gptdata.guid[7], gptdata.guid[6], gptdata.guid[8],
+			   gptdata.guid[9], gptdata.guid[10], gptdata.guid[11],
+			   gptdata.guid[12], gptdata.guid[13], gptdata.guid[14],
+			   gptdata.guid[15]);
+	    }
+	  disk->partition = p;
+	}
+    }
+}
+
+static void
 probe_cryptodisk_uuid (grub_disk_t disk, char delim)
 {
   grub_disk_memberlist_t list = NULL, tmp;
@@ -621,6 +675,12 @@ probe (const char *path, char **device_names, char delim)
 	/* Check if dev->disk itself is contained in a partmap.  */
 	probe_partmap (dev->disk, delim);
 
+      else if (print == PRINT_PARTUUID)
+	{
+	  probe_partuuid (dev->disk, delim);
+	  putchar (delim);
+	}
+
       else if (print == PRINT_MSDOS_PARTTYPE)
 	{
 	  if (dev->disk->partition
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [GRUB PARTUUID PATCH V3 3/5] Update grub script template files
  2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue Nicholas Vinson
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 2/5] Add PARTUUID detection support to grub-probe Nicholas Vinson
@ 2017-02-27  0:20 ` Nicholas Vinson
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val Nicholas Vinson
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Nicholas Vinson @ 2017-02-27  0:20 UTC (permalink / raw)
  To: skenton, grub-devel

Update grub-mkconfig.in and 10_linux.in to support grub-probe's new
partuuid target.  Update grub.texi documenation.
---
 docs/grub.texi          | 13 +++++++++++++
 util/grub-mkconfig.in   |  3 +++
 util/grub.d/10_linux.in | 13 +++++++++++--
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/docs/grub.texi b/docs/grub.texi
index e935af33e..289b202df 100644
--- a/docs/grub.texi
+++ b/docs/grub.texi
@@ -1405,6 +1405,19 @@ the Linux kernel, using a @samp{root=UUID=...} kernel parameter.  This is
 usually more reliable, but in some cases it may not be appropriate.  To
 disable the use of UUIDs, set this option to @samp{true}.
 
+@item GRUB_ENABLE_LINUX_PARTUUID
+Normally, when @command{grub-mkconfig} sets the @samp{root=UUID=...} kernel
+parameter, it selects a filesystem UUID.  This works well for Linux systems that
+boot using an initramfs as most implementations support mounting the root
+filesystem this way.  However for Linux systems that do not boot using an
+initramfs, @command{grub-mkconfig} defaults to setting the @samp{root=...}
+kernel parameter to the device name containing the root filesystem.  Setting
+this option to @samp{true} changes the behavior of @command{grub-mkconfig} so
+that it identifies the device containing the root filesystem by the partition
+UUID.  In order to use the @samp{root=PARTUUID=...} kernel parameter, the Linux
+kernel version must be at least 2.6.37 (3.10 for systems using the MSDOS
+partition scheme).
+
 @item GRUB_DISABLE_RECOVERY
 If this option is set to @samp{true}, disable the generation of recovery
 mode menu entries.
diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in
index f8496d28b..30ead59e1 100644
--- a/util/grub-mkconfig.in
+++ b/util/grub-mkconfig.in
@@ -134,6 +134,7 @@ fi
 # Device containing our userland.  Typically used for root= parameter.
 GRUB_DEVICE="`${grub_probe} --target=device /`"
 GRUB_DEVICE_UUID="`${grub_probe} --device ${GRUB_DEVICE} --target=fs_uuid 2> /dev/null`" || true
+GRUB_DEVICE_PARTUUID="`${grub_probe} --device ${GRUB_DEVICE} --target=partuuid 2> /dev/null`" || true
 
 # Device containing our /boot partition.  Usually the same as GRUB_DEVICE.
 GRUB_DEVICE_BOOT="`${grub_probe} --target=device /boot`"
@@ -182,6 +183,7 @@ if [ "x${GRUB_ACTUAL_DEFAULT}" = "xsaved" ] ; then GRUB_ACTUAL_DEFAULT="`"${grub
 # override them.
 export GRUB_DEVICE \
   GRUB_DEVICE_UUID \
+  GRUB_DEVICE_PARTUUID \
   GRUB_DEVICE_BOOT \
   GRUB_DEVICE_BOOT_UUID \
   GRUB_FS \
@@ -215,6 +217,7 @@ export GRUB_DEFAULT \
   GRUB_TERMINAL_OUTPUT \
   GRUB_SERIAL_COMMAND \
   GRUB_DISABLE_LINUX_UUID \
+  GRUB_ENABLE_LINUX_PARTUUID \
   GRUB_DISABLE_RECOVERY \
   GRUB_VIDEO_BACKEND \
   GRUB_GFXMODE \
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
index de9044c7f..71675fac6 100644
--- a/util/grub.d/10_linux.in
+++ b/util/grub.d/10_linux.in
@@ -220,8 +220,17 @@ while [ "x$list" != "x" ] ; do
     gettext_printf "Found initrd image: %s\n" "${dirname}/${initrd}" >&2
   elif test -z "${initramfs}" ; then
     # "UUID=" and "ZFS=" magic is parsed by initrd or initramfs.  Since there's
-    # no initrd or builtin initramfs, it can't work here.
-    linux_root_device_thisversion=${GRUB_DEVICE}
+    # no initrd or builtin initramfs, it can't work here.  However, if
+    # GRUB_DEVICE_PARTUUID is not empty we can use that here if
+    # GRUD_DISABLE_LINUX_UUID is not set to true and GRUB_ENABLE_LINUX_PARTUUID
+    # is set to true.
+    if [ "x${GRUB_DISABLE_LINUX_UUID}" != "xtrue" ] \
+        && [ "x${GRUB_DEVICE_PARTUUID}" != "x" ]    \
+        && [ "x${GRUB_ENABLE_LINUX_PARTUUID}" = "xtrue" ] ; then
+        linux_root_device_thisversion="PARTUUID=${GRUB_DEVICE_PARTUUID}"
+    else
+        linux_root_device_thisversion=${GRUB_DEVICE}
+    fi
   fi
 
   if [ "x$is_top_level" = xtrue ] && [ "x${GRUB_DISABLE_SUBMENU}" != xy ]; then
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val
  2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
                   ` (2 preceding siblings ...)
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 3/5] Update grub script template files Nicholas Vinson
@ 2017-02-27  0:20 ` Nicholas Vinson
  2017-02-27  0:35   ` Vladimir 'phcoder' Serbinenko
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 5/5] Harmonize patches Nicholas Vinson
  2017-05-09  3:22 ` [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nick Vinson
  5 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2017-02-27  0:20 UTC (permalink / raw)
  To: skenton, grub-devel

From: Steve Kenton <address@hidden>

---
 grub-core/commands/probe.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)

diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
index cf2793e1d..5dd1a6bc5 100644
--- a/grub-core/commands/probe.c
+++ b/grub-core/commands/probe.c
@@ -16,6 +16,7 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <stddef.h>
 #include <grub/types.h>
 #include <grub/misc.h>
 #include <grub/mm.h>
@@ -24,6 +25,8 @@
 #include <grub/device.h>
 #include <grub/disk.h>
 #include <grub/partition.h>
+#include <grub/gpt_partition.h>
+#include <grub/i386/pc/boot.h>
 #include <grub/net.h>
 #include <grub/fs.h>
 #include <grub/file.h>
@@ -45,6 +48,7 @@ static const struct grub_arg_option options[] =
     {"fs",		'f', 0, N_("Determine filesystem type."), 0, 0},
     {"fs-uuid",		'u', 0, N_("Determine filesystem UUID."), 0, 0},
     {"label",		'l', 0, N_("Determine filesystem label."), 0, 0},
+    {"partuuid",	'g', 0, N_("Determine partition GUID/UUID."), 0, 0}, /* GUID but Linux kernel calls it "PARTUUID" */
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -154,6 +158,61 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
       grub_device_close (dev);
       return GRUB_ERR_NONE;
     }
+  if (state[6].set)
+    {
+      char *partuuid = NULL; /* NULL to silence a spurious GCC warning */
+      /* Nested partitions are not supported for now. */
+      /* Non-nested partitions must have dev->disk->partition->parent == NULL */
+      if (dev->disk && dev->disk->partition && dev->disk->partition->parent == NULL)
+       {
+	 grub_partition_t p = dev->disk->partition;
+	 if (grub_strcmp (p->partmap->name, "msdos") == 0)
+	   {
+             /* little-endian 4-byte NT disk id "GUID" in the MBR */
+             grub_uint8_t diskid[4];
+	     dev->disk->partition = p->parent;
+	     grub_uint32_t nt_disk_sig;
+	     err = grub_disk_read (dev->disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, sizeof(diskid), diskid);
+	     dev->disk->partition = p;
+	     if (err)
+	       return grub_errno;
+	     /* partition numbers are one-based */
+	     partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
+					diskid[3], diskid[2], diskid[1], disk[0],
+					p->number + 1);
+	   }
+	 else if (grub_strcmp (p->partmap->name, "gpt") == 0)
+	   {
+	     struct grub_gpt_partentry e;
+	     dev->disk->partition = p->parent;
+	     err = grub_disk_read (dev->disk, p->offset, p->index, sizeof e, &e);
+	     dev->disk->partition = p;
+	     if (err)
+	       return grub_errno;
+
+	     partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+					e.guid[3], e.guid[2], e.guid[1], e.guid[0],
+					e.guid[5], e.guid[4],
+					e.guid[7], e.guid[6],
+					e.guid[8], e.guid[9],
+					e.guid[10], e.guid[11], e.guid[12], e.guid[13], e.guid[14], e.guid[15]);
+	   }
+	 else
+	   return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
+			      N_("partition map %s does not support partition UUIDs"),
+			      dev->disk->partition->partmap->name);
+       }
+      else
+       partuuid = grub_strdup (""); /* a freeable empty string */
+
+      if (state[0].set)
+	grub_env_set (state[0].arg, partuuid);
+      else
+	grub_printf ("%s", partuuid);
+      grub_free (partuuid);
+      grub_device_close (dev);
+      return GRUB_ERR_NONE;
+    }
   grub_device_close (dev);
   return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised target");
 }
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [GRUB PARTUUID PATCH V3 5/5] Harmonize patches
  2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
                   ` (3 preceding siblings ...)
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val Nicholas Vinson
@ 2017-02-27  0:20 ` Nicholas Vinson
  2017-02-27  0:34   ` Vladimir 'phcoder' Serbinenko
  2017-05-09  3:22 ` [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nick Vinson
  5 siblings, 1 reply; 14+ messages in thread
From: Nicholas Vinson @ 2017-02-27  0:20 UTC (permalink / raw)
  To: skenton, grub-devel

Optional patch.  The goal is to make sure the probe command used in both
the grub core and the Linux userland use similar methods to read the
partition GUIDs.  The patch also updates include/grub/gpt_partition.h so
the GUID type struct can be used for both the type GUID and the
partition GUID without using any confusing naming.

The patch also includes formatting corrections to make sure all changed
lines are no longer than 80 columns.
---
 grub-core/commands/probe.c   | 57 +++++++++++++++++++++++++++++---------------
 grub-core/disk/ldm.c         |  2 +-
 grub-core/partmap/gpt.c      |  4 ++--
 include/grub/gpt_partition.h |  8 +++----
 util/grub-install.c          |  2 +-
 util/grub-probe.c            | 41 +++++++++++++------------------
 6 files changed, 62 insertions(+), 52 deletions(-)

diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
index 5dd1a6bc5..d58ee89aa 100644
--- a/grub-core/commands/probe.c
+++ b/grub-core/commands/probe.c
@@ -16,7 +16,6 @@
  *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <stddef.h>
 #include <grub/types.h>
 #include <grub/misc.h>
 #include <grub/mm.h>
@@ -48,10 +47,25 @@ static const struct grub_arg_option options[] =
     {"fs",		'f', 0, N_("Determine filesystem type."), 0, 0},
     {"fs-uuid",		'u', 0, N_("Determine filesystem UUID."), 0, 0},
     {"label",		'l', 0, N_("Determine filesystem label."), 0, 0},
-    {"partuuid",	'g', 0, N_("Determine partition GUID/UUID."), 0, 0}, /* GUID but Linux kernel calls it "PARTUUID" */
+    /* GUID but Linux kernel calls it "PARTUUID" */
+    {"partuuid",	'g', 0, N_("Determine partition GUID/UUID."), 0, 0},
     {0, 0, 0, 0, 0, 0}
   };
 
+static char *
+sprint_gpt_guid (grub_gpt_part_guid_t guid)
+{
+  guid.data1 = grub_le_to_cpu32 (guid.data1);
+  guid.data2 = grub_le_to_cpu16 (guid.data2);
+  guid.data3 = grub_le_to_cpu16 (guid.data3);
+
+  return grub_xasprintf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+			 guid.data1, guid.data2, guid.data3, guid.data4[0],
+			 guid.data4[1], guid.data4[2], guid.data4[3],
+			 guid.data4[4], guid.data4[5], guid.data4[6],
+			 guid.data4[7]);
+}
+
 static grub_err_t
 grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
 {
@@ -161,45 +175,50 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
   if (state[6].set)
     {
       char *partuuid = NULL; /* NULL to silence a spurious GCC warning */
-      /* Nested partitions are not supported for now. */
-      /* Non-nested partitions must have dev->disk->partition->parent == NULL */
-      if (dev->disk && dev->disk->partition && dev->disk->partition->parent == NULL)
+      /*
+       * Nested partitions are not supported for now.
+       * Non-nested partitions must have dev->disk->partition->parent == NULL
+       */
+      if (dev->disk && dev->disk->partition
+	  && dev->disk->partition->parent == NULL)
        {
 	 grub_partition_t p = dev->disk->partition;
 	 if (grub_strcmp (p->partmap->name, "msdos") == 0)
 	   {
-             /* little-endian 4-byte NT disk id "GUID" in the MBR */
-             grub_uint8_t diskid[4];
+	     /*
+	      * The partition GUID for MSDOS is the partition number (starting
+	      * with 1) prepended with the NT disk signature.
+	      */
 	     dev->disk->partition = p->parent;
 	     grub_uint32_t nt_disk_sig;
-	     err = grub_disk_read (dev->disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, sizeof(diskid), diskid);
+	     err = grub_disk_read (dev->disk, 0,
+				   GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
+				   sizeof(nt_disk_sig), &nt_disk_sig);
 	     dev->disk->partition = p;
 	     if (err)
 	       return grub_errno;
 	     /* partition numbers are one-based */
-	     partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
-					diskid[3], diskid[2], diskid[1], disk[0],
+	     partuuid = grub_xasprintf ("%08x-%02x",
+					grub_le_to_cpu32(nt_disk_sig),
 					p->number + 1);
 	   }
 	 else if (grub_strcmp (p->partmap->name, "gpt") == 0)
 	   {
-	     struct grub_gpt_partentry e;
+	     struct grub_gpt_partentry gptdata;
+
 	     dev->disk->partition = p->parent;
-	     err = grub_disk_read (dev->disk, p->offset, p->index, sizeof e, &e);
+	     err = grub_disk_read (dev->disk, p->offset, p->index,
+				   sizeof gptdata, &gptdata);
 	     dev->disk->partition = p;
 	     if (err)
 	       return grub_errno;
 
-	     partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
-					e.guid[3], e.guid[2], e.guid[1], e.guid[0],
-					e.guid[5], e.guid[4],
-					e.guid[7], e.guid[6],
-					e.guid[8], e.guid[9],
-					e.guid[10], e.guid[11], e.guid[12], e.guid[13], e.guid[14], e.guid[15]);
+	     partuuid = sprint_gpt_guid(gptdata.guid);
 	   }
 	 else
 	   return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
-			      N_("partition map %s does not support partition UUIDs"),
+			      N_("partition map %s does not support "
+				 "partition UUIDs"),
 			      dev->disk->partition->partmap->name);
        }
       else
diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
index 0f978ad05..2a22d2d6c 100644
--- a/grub-core/disk/ldm.c
+++ b/grub-core/disk/ldm.c
@@ -135,7 +135,7 @@ msdos_has_ldm_partition (grub_disk_t dsk)
   return has_ldm;
 }
 
-static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
+static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
 
 /* Helper for gpt_ldm_sector.  */
 static int
diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
index 83bcba779..103f6796f 100644
--- a/grub-core/partmap/gpt.c
+++ b/grub-core/partmap/gpt.c
@@ -33,10 +33,10 @@ static grub_uint8_t grub_gpt_magic[8] =
     0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
   };
 
-static const grub_gpt_part_type_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
+static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY;
 
 #ifdef GRUB_UTIL
-static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
+static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
 #endif
 
 /* 512 << 7 = 65536 byte sectors.  */
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index 1b32f6725..354fe2246 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -22,14 +22,14 @@
 #include <grub/types.h>
 #include <grub/partition.h>
 
-struct grub_gpt_part_type
+struct grub_gpt_part_guid
 {
   grub_uint32_t data1;
   grub_uint16_t data2;
   grub_uint16_t data3;
   grub_uint8_t data4[8];
 } __attribute__ ((aligned(8)));
-typedef struct grub_gpt_part_type grub_gpt_part_type_t;
+typedef struct grub_gpt_part_guid grub_gpt_part_guid_t;
 
 #define GRUB_GPT_PARTITION_TYPE_EMPTY \
   { 0x0, 0x0, 0x0, \
@@ -70,8 +70,8 @@ struct grub_gpt_header
 
 struct grub_gpt_partentry
 {
-  grub_gpt_part_type_t type;
-  grub_uint8_t guid[16];
+  grub_gpt_part_guid_t type;
+  grub_gpt_part_guid_t guid;
   grub_uint64_t start;
   grub_uint64_t end;
   grub_uint64_t attrib;
diff --git a/util/grub-install.c b/util/grub-install.c
index 6c89c2b0c..23b0acb50 100644
--- a/util/grub-install.c
+++ b/util/grub-install.c
@@ -713,7 +713,7 @@ is_prep_partition (grub_device_t dev)
       if (grub_disk_read (dev->disk, p->offset, p->index,
 			  sizeof (gptdata), &gptdata) == 0)
 	{
-	  const grub_gpt_part_type_t template = {
+	  const grub_gpt_part_guid_t template = {
 	    grub_cpu_to_le32_compile_time (0x9e1a2d38),
 	    grub_cpu_to_le16_compile_time (0xc612),
 	    grub_cpu_to_le16_compile_time (0x4316),
diff --git a/util/grub-probe.c b/util/grub-probe.c
index 81f550e0d..3656e32e8 100644
--- a/util/grub-probe.c
+++ b/util/grub-probe.c
@@ -132,6 +132,20 @@ get_targets_string (void)
   return str;
 }
 
+static int
+print_gpt_guid (grub_gpt_part_guid_t guid)
+{
+  guid.data1 = grub_le_to_cpu32 (guid.data1);
+  guid.data2 = grub_le_to_cpu16 (guid.data2);
+  guid.data3 = grub_le_to_cpu16 (guid.data3);
+
+  return grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+		      guid.data1, guid.data2, guid.data3, guid.data4[0],
+		      guid.data4[1], guid.data4[2], guid.data4[3],
+		      guid.data4[4], guid.data4[5], guid.data4[6],
+		      guid.data4[7]);
+}
+
 static void
 do_print (const char *x, void *data)
 {
@@ -206,16 +220,7 @@ probe_partuuid (grub_disk_t disk, char delim)
 
 	  if (grub_disk_read (disk, p->offset, p->index,
 			      sizeof(gptdata), &gptdata) == 0)
-	    {
-	      grub_printf ("%02x%02x%02x%02x-%02x%02x-%02x%02x"
-			   "-%02x%02x-%02x%02x%02x%02x%02x%02x",
-			   gptdata.guid[3], gptdata.guid[2], gptdata.guid[1],
-			   gptdata.guid[0], gptdata.guid[5], gptdata.guid[4],
-			   gptdata.guid[7], gptdata.guid[6], gptdata.guid[8],
-			   gptdata.guid[9], gptdata.guid[10], gptdata.guid[11],
-			   gptdata.guid[12], gptdata.guid[13], gptdata.guid[14],
-			   gptdata.guid[15]);
-	    }
+	    print_gpt_guid(gptdata.guid);
 	  disk->partition = p;
 	}
     }
@@ -701,21 +706,7 @@ probe (const char *path, char **device_names, char delim)
 
               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]);
-                }
+		print_gpt_guid(gptdata.type);
               dev->disk->partition = p;
             }
           putchar (delim);
-- 
2.12.0



^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue Nicholas Vinson
@ 2017-02-27  0:28   ` Vladimir 'phcoder' Serbinenko
  2017-02-27  4:34     ` Andrei Borzenkov
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-27  0:28 UTC (permalink / raw)
  To: The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]

Please explain why this patch is needed. I compile with 2.6.1 just fine

On Sun, Feb 26, 2017, 16:22 Nicholas Vinson <nvinson234@gmail.com> wrote:

> ---
>  grub-core/script/yylex.l | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
> index 95b219170..3917904b4 100644
> --- a/grub-core/script/yylex.l
> +++ b/grub-core/script/yylex.l
> @@ -31,10 +31,6 @@
>  #pragma GCC diagnostic ignored "-Wunused-function"
>  #pragma GCC diagnostic ignored "-Wsign-compare"
>
> -#define yyalloc(size, scanner)   (grub_malloc((size)))
> -#define yyfree(ptr, scanner)   (grub_free((ptr)))
> -#define yyrealloc(ptr, size, scanner) (grub_realloc((ptr), (size)))
> -
>  /*
>   * As we don't have access to yyscanner, we cannot do much except to
>   * print the fatal error.
> @@ -327,6 +323,24 @@ POS_MULTILINE   {WORD}?\\\n
>                  }
>  %%
>
> +void *
> +yyalloc(yy_size_t size, yyscan_t yyscanner)
> +{
>
This is missing __attribute__ ((unused)) for second argument

> +  return grub_malloc(size);
> +}
> +
> +void
> +yyfree(void *ptr, yyscan_t yyscanner)
> +{
>
Ditto

> +  return grub_free(ptr);
> +}
> +
> +void *
> +yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
> +{
>
Ditto

> +  return grub_realloc(ptr, size);
> +}
> +
>  int
>  yywrap (yyscan_t yyscanner)
>  {
> --
> 2.12.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 3563 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 5/5] Harmonize patches
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 5/5] Harmonize patches Nicholas Vinson
@ 2017-02-27  0:34   ` Vladimir 'phcoder' Serbinenko
  2017-02-27 18:03     ` Andrei Borzenkov
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-27  0:34 UTC (permalink / raw)
  To: The development of GNU GRUB, skenton

[-- Attachment #1: Type: text/plain, Size: 12280 bytes --]

On Sun, Feb 26, 2017, 16:23 Nicholas Vinson <nvinson234@gmail.com> wrote:

> Optional patch.  The goal is to make sure the probe command used in both
> the grub core and the Linux userland use similar methods to read the
> partition GUIDs.  The patch also updates include/grub/gpt_partition.h so
> the GUID type struct can be used for both the type GUID and the
> partition GUID without using any confusing naming.
>
> The patch also includes formatting corrections to make sure all changed
> lines are no longer than 80 columns.
> ---
>  grub-core/commands/probe.c   | 57
> +++++++++++++++++++++++++++++---------------
>  grub-core/disk/ldm.c         |  2 +-
>  grub-core/partmap/gpt.c      |  4 ++--
>  include/grub/gpt_partition.h |  8 +++----
>  util/grub-install.c          |  2 +-
>  util/grub-probe.c            | 41 +++++++++++++------------------
>  6 files changed, 62 insertions(+), 52 deletions(-)
>
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index 5dd1a6bc5..d58ee89aa 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c
> @@ -16,7 +16,6 @@
>   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> -#include <stddef.h>
>  #include <grub/types.h>
>  #include <grub/misc.h>
>  #include <grub/mm.h>
> @@ -48,10 +47,25 @@ static const struct grub_arg_option options[] =
>      {"fs",             'f', 0, N_("Determine filesystem type."), 0, 0},
>      {"fs-uuid",                'u', 0, N_("Determine filesystem UUID."),
> 0, 0},
>      {"label",          'l', 0, N_("Determine filesystem label."), 0, 0},
> -    {"partuuid",       'g', 0, N_("Determine partition GUID/UUID."), 0,
> 0}, /* GUID but Linux kernel calls it "PARTUUID" */
> +    /* GUID but Linux kernel calls it "PARTUUID" */
> +    {"partuuid",       'g', 0, N_("Determine partition GUID/UUID."), 0,
> 0},
>      {0, 0, 0, 0, 0, 0}
>    };
>
> +static char *
> +sprint_gpt_guid (grub_gpt_part_guid_t guid)
> +{
> +  guid.data1 = grub_le_to_cpu32 (guid.data1);
> +  guid.data2 = grub_le_to_cpu16 (guid.data2);
> +  guid.data3 = grub_le_to_cpu16 (guid.data3);
> +
> +  return grub_xasprintf
> ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> +                        guid.data1, guid.data2, guid.data3, guid.data4[0],
> +                        guid.data4[1], guid.data4[2], guid.data4[3],
> +                        guid.data4[4], guid.data4[5], guid.data4[6],
> +                        guid.data4[7]);
> +}
> +
>  static grub_err_t
>  grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
>  {
> @@ -161,45 +175,50 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int
> argc, char **args)
>    if (state[6].set)
>      {
>        char *partuuid = NULL; /* NULL to silence a spurious GCC warning */
> -      /* Nested partitions are not supported for now. */
> -      /* Non-nested partitions must have dev->disk->partition->parent ==
> NULL */
> -      if (dev->disk && dev->disk->partition &&
> dev->disk->partition->parent == NULL)
> +      /*
> +       * Nested partitions are not supported for now.
> +       * Non-nested partitions must have dev->disk->partition->parent ==
> NULL
> +       */
>
I'm not sure that this is enough. In presence of nested partitions Linux
may shift extended partitions as well. I think we need to do tests with
qemu and bsd-formatted partitions

> +      if (dev->disk && dev->disk->partition
> +         && dev->disk->partition->parent == NULL)
>         {
>          grub_partition_t p = dev->disk->partition;
>          if (grub_strcmp (p->partmap->name, "msdos") == 0)
>            {
> -             /* little-endian 4-byte NT disk id "GUID" in the MBR */
> -             grub_uint8_t diskid[4];
> +            /*
> +             * The partition GUID for MSDOS is the partition number
> (starting
> +             * with 1) prepended with the NT disk signature.
> +             */
>              dev->disk->partition = p->parent;
>              grub_uint32_t nt_disk_sig;
> -            err = grub_disk_read (dev->disk, 0,
> GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, sizeof(diskid), diskid);
> +            err = grub_disk_read (dev->disk, 0,
> +                                  GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC,
> +                                  sizeof(nt_disk_sig), &nt_disk_sig);
>              dev->disk->partition = p;
>              if (err)
>                return grub_errno;
>              /* partition numbers are one-based */
> -            partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
> -                                       diskid[3], diskid[2], diskid[1],
> disk[0],
> +            partuuid = grub_xasprintf ("%08x-%02x",
> +                                       grub_le_to_cpu32(nt_disk_sig),
>                                         p->number + 1);
>            }
>          else if (grub_strcmp (p->partmap->name, "gpt") == 0)
>            {
> -            struct grub_gpt_partentry e;
> +            struct grub_gpt_partentry gptdata;
> +
>              dev->disk->partition = p->parent;
> -            err = grub_disk_read (dev->disk, p->offset, p->index, sizeof
> e, &e);
> +            err = grub_disk_read (dev->disk, p->offset, p->index,
> +                                  sizeof gptdata, &gptdata);
>              dev->disk->partition = p;
>              if (err)
>                return grub_errno;
>
> -            partuuid = grub_xasprintf
> ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> -                                       e.guid[3], e.guid[2], e.guid[1],
> e.guid[0],
> -                                       e.guid[5], e.guid[4],
> -                                       e.guid[7], e.guid[6],
> -                                       e.guid[8], e.guid[9],
> -                                       e.guid[10], e.guid[11],
> e.guid[12], e.guid[13], e.guid[14], e.guid[15]);
> +            partuuid = sprint_gpt_guid(gptdata.guid);
>            }
>          else
>            return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
> -                             N_("partition map %s does not support
> partition UUIDs"),
> +                             N_("partition map %s does not support "
> +                                "partition UUIDs"),
>                               dev->disk->partition->partmap->name);
>         }
>        else
> diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c
> index 0f978ad05..2a22d2d6c 100644
> --- a/grub-core/disk/ldm.c
> +++ b/grub-core/disk/ldm.c
> @@ -135,7 +135,7 @@ msdos_has_ldm_partition (grub_disk_t dsk)
>    return has_ldm;
>  }
>
> -static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
> +static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM;
>
>  /* Helper for gpt_ldm_sector.  */
>  static int
> diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c
> index 83bcba779..103f6796f 100644
> --- a/grub-core/partmap/gpt.c
> +++ b/grub-core/partmap/gpt.c
> @@ -33,10 +33,10 @@ static grub_uint8_t grub_gpt_magic[8] =
>      0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54
>    };
>
> -static const grub_gpt_part_type_t grub_gpt_partition_type_empty =
> GRUB_GPT_PARTITION_TYPE_EMPTY;
> +static const grub_gpt_part_guid_t grub_gpt_partition_type_empty =
> GRUB_GPT_PARTITION_TYPE_EMPTY;
>
>  #ifdef GRUB_UTIL
> -static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot =
> GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
> +static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot =
> GRUB_GPT_PARTITION_TYPE_BIOS_BOOT;
>  #endif
>
>  /* 512 << 7 = 65536 byte sectors.  */
> diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
> index 1b32f6725..354fe2246 100644
> --- a/include/grub/gpt_partition.h
> +++ b/include/grub/gpt_partition.h
> @@ -22,14 +22,14 @@
>  #include <grub/types.h>
>  #include <grub/partition.h>
>
> -struct grub_gpt_part_type
> +struct grub_gpt_part_guid
>  {
>    grub_uint32_t data1;
>    grub_uint16_t data2;
>    grub_uint16_t data3;
>    grub_uint8_t data4[8];
>  } __attribute__ ((aligned(8)));
> -typedef struct grub_gpt_part_type grub_gpt_part_type_t;
> +typedef struct grub_gpt_part_guid grub_gpt_part_guid_t;
>
>  #define GRUB_GPT_PARTITION_TYPE_EMPTY \
>    { 0x0, 0x0, 0x0, \
> @@ -70,8 +70,8 @@ struct grub_gpt_header
>
>  struct grub_gpt_partentry
>  {
> -  grub_gpt_part_type_t type;
> -  grub_uint8_t guid[16];
> +  grub_gpt_part_guid_t type;
> +  grub_gpt_part_guid_t guid;
>    grub_uint64_t start;
>    grub_uint64_t end;
>    grub_uint64_t attrib;
> diff --git a/util/grub-install.c b/util/grub-install.c
> index 6c89c2b0c..23b0acb50 100644
> --- a/util/grub-install.c
> +++ b/util/grub-install.c
> @@ -713,7 +713,7 @@ is_prep_partition (grub_device_t dev)
>        if (grub_disk_read (dev->disk, p->offset, p->index,
>                           sizeof (gptdata), &gptdata) == 0)
>         {
> -         const grub_gpt_part_type_t template = {
> +         const grub_gpt_part_guid_t template = {
>             grub_cpu_to_le32_compile_time (0x9e1a2d38),
>             grub_cpu_to_le16_compile_time (0xc612),
>             grub_cpu_to_le16_compile_time (0x4316),
> diff --git a/util/grub-probe.c b/util/grub-probe.c
> index 81f550e0d..3656e32e8 100644
> --- a/util/grub-probe.c
> +++ b/util/grub-probe.c
> @@ -132,6 +132,20 @@ get_targets_string (void)
>    return str;
>  }
>
> +static int
> +print_gpt_guid (grub_gpt_part_guid_t guid)
> +{
> +  guid.data1 = grub_le_to_cpu32 (guid.data1);
> +  guid.data2 = grub_le_to_cpu16 (guid.data2);
> +  guid.data3 = grub_le_to_cpu16 (guid.data3);
> +
> +  return grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> +                     guid.data1, guid.data2, guid.data3, guid.data4[0],
> +                     guid.data4[1], guid.data4[2], guid.data4[3],
> +                     guid.data4[4], guid.data4[5], guid.data4[6],
> +                     guid.data4[7]);
> +}
> +
>  static void
>  do_print (const char *x, void *data)
>  {
> @@ -206,16 +220,7 @@ probe_partuuid (grub_disk_t disk, char delim)
>
>           if (grub_disk_read (disk, p->offset, p->index,
>                               sizeof(gptdata), &gptdata) == 0)
> -           {
> -             grub_printf ("%02x%02x%02x%02x-%02x%02x-%02x%02x"
> -                          "-%02x%02x-%02x%02x%02x%02x%02x%02x",
> -                          gptdata.guid[3], gptdata.guid[2],
> gptdata.guid[1],
> -                          gptdata.guid[0], gptdata.guid[5],
> gptdata.guid[4],
> -                          gptdata.guid[7], gptdata.guid[6],
> gptdata.guid[8],
> -                          gptdata.guid[9], gptdata.guid[10],
> gptdata.guid[11],
> -                          gptdata.guid[12], gptdata.guid[13],
> gptdata.guid[14],
> -                          gptdata.guid[15]);
> -           }
> +           print_gpt_guid(gptdata.guid);
>           disk->partition = p;
>         }
>      }
> @@ -701,21 +706,7 @@ probe (const char *path, char **device_names, char
> delim)
>
>                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]);
> -                }
> +               print_gpt_guid(gptdata.type);
>                dev->disk->partition = p;
>              }
>            putchar (delim);
> --
> 2.12.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 20424 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val Nicholas Vinson
@ 2017-02-27  0:35   ` Vladimir 'phcoder' Serbinenko
  2017-02-27  5:54     ` Andrei Borzenkov
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-27  0:35 UTC (permalink / raw)
  To: The development of GNU GRUB, skenton

[-- Attachment #1: Type: text/plain, Size: 4568 bytes --]

On Sun, Feb 26, 2017, 16:22 Nicholas Vinson <nvinson234@gmail.com> wrote:

> From: Steve Kenton <address@hidden>
>
Please avoid resubmitting patches made by someone else in most cases. It
obscures proper attribution. We can review his patch in his thread

>
> ---
>  grub-core/commands/probe.c | 59
> ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 59 insertions(+)
>
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index cf2793e1d..5dd1a6bc5 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c
> @@ -16,6 +16,7 @@
>   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>   */
>
> +#include <stddef.h>
>  #include <grub/types.h>
>  #include <grub/misc.h>
>  #include <grub/mm.h>
> @@ -24,6 +25,8 @@
>  #include <grub/device.h>
>  #include <grub/disk.h>
>  #include <grub/partition.h>
> +#include <grub/gpt_partition.h>
> +#include <grub/i386/pc/boot.h>
>  #include <grub/net.h>
>  #include <grub/fs.h>
>  #include <grub/file.h>
> @@ -45,6 +48,7 @@ static const struct grub_arg_option options[] =
>      {"fs",             'f', 0, N_("Determine filesystem type."), 0, 0},
>      {"fs-uuid",                'u', 0, N_("Determine filesystem UUID."),
> 0, 0},
>      {"label",          'l', 0, N_("Determine filesystem label."), 0, 0},
> +    {"partuuid",       'g', 0, N_("Determine partition GUID/UUID."), 0,
> 0}, /* GUID but Linux kernel calls it "PARTUUID" */
>      {0, 0, 0, 0, 0, 0}
>    };
>
> @@ -154,6 +158,61 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc,
> char **args)
>        grub_device_close (dev);
>        return GRUB_ERR_NONE;
>      }
> +  if (state[6].set)
> +    {
> +      char *partuuid = NULL; /* NULL to silence a spurious GCC warning */
> +      /* Nested partitions are not supported for now. */
> +      /* Non-nested partitions must have dev->disk->partition->parent ==
> NULL */
> +      if (dev->disk && dev->disk->partition &&
> dev->disk->partition->parent == NULL)
> +       {
> +        grub_partition_t p = dev->disk->partition;
> +        if (grub_strcmp (p->partmap->name, "msdos") == 0)
> +          {
> +             /* little-endian 4-byte NT disk id "GUID" in the MBR */
> +             grub_uint8_t diskid[4];
> +            dev->disk->partition = p->parent;
> +            grub_uint32_t nt_disk_sig;
> +            err = grub_disk_read (dev->disk, 0,
> GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, sizeof(diskid), diskid);
> +            dev->disk->partition = p;
> +            if (err)
> +              return grub_errno;
> +            /* partition numbers are one-based */
> +            partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
> +                                       diskid[3], diskid[2], diskid[1],
> disk[0],
> +                                       p->number + 1);
> +          }
> +        else if (grub_strcmp (p->partmap->name, "gpt") == 0)
> +          {
> +            struct grub_gpt_partentry e;
> +            dev->disk->partition = p->parent;
> +            err = grub_disk_read (dev->disk, p->offset, p->index, sizeof
> e, &e);
> +            dev->disk->partition = p;
> +            if (err)
> +              return grub_errno;
> +
> +            partuuid = grub_xasprintf
> ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> +                                       e.guid[3], e.guid[2], e.guid[1],
> e.guid[0],
> +                                       e.guid[5], e.guid[4],
> +                                       e.guid[7], e.guid[6],
> +                                       e.guid[8], e.guid[9],
> +                                       e.guid[10], e.guid[11],
> e.guid[12], e.guid[13], e.guid[14], e.guid[15]);
> +          }
> +        else
> +          return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
> +                             N_("partition map %s does not support
> partition UUIDs"),
> +                             dev->disk->partition->partmap->name);
> +       }
> +      else
> +       partuuid = grub_strdup (""); /* a freeable empty string */
> +
> +      if (state[0].set)
> +       grub_env_set (state[0].arg, partuuid);
> +      else
> +       grub_printf ("%s", partuuid);
> +      grub_free (partuuid);
> +      grub_device_close (dev);
> +      return GRUB_ERR_NONE;
> +    }
>    grub_device_close (dev);
>    return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised target");
>  }
> --
> 2.12.0
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

[-- Attachment #2: Type: text/html, Size: 8275 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue
  2017-02-27  0:28   ` Vladimir 'phcoder' Serbinenko
@ 2017-02-27  4:34     ` Andrei Borzenkov
  0 siblings, 0 replies; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-27  4:34 UTC (permalink / raw)
  To: The development of GNU GRUB

27.02.2017 03:28, Vladimir 'phcoder' Serbinenko пишет:
> Please explain why this patch is needed. I compile with 2.6.1 just fine
> 

There is bug introduced in flex 2.6.2 (I believe) and fixed in current
git, so in to be released 2.6.4. See

https://savannah.gnu.org/bugs/index.php?50093
https://github.com/westes/flex/issues/162

As this is really flex bug that is present only in specific version and
affects more than one project, I do not think we need special
workaround. We may mention in INSTALL to avoid these versions though.

> On Sun, Feb 26, 2017, 16:22 Nicholas Vinson <nvinson234@gmail.com> wrote:
> 
>> ---
>>  grub-core/script/yylex.l | 22 ++++++++++++++++++----
>>  1 file changed, 18 insertions(+), 4 deletions(-)
>>
>> diff --git a/grub-core/script/yylex.l b/grub-core/script/yylex.l
>> index 95b219170..3917904b4 100644
>> --- a/grub-core/script/yylex.l
>> +++ b/grub-core/script/yylex.l
>> @@ -31,10 +31,6 @@
>>  #pragma GCC diagnostic ignored "-Wunused-function"
>>  #pragma GCC diagnostic ignored "-Wsign-compare"
>>
>> -#define yyalloc(size, scanner)   (grub_malloc((size)))
>> -#define yyfree(ptr, scanner)   (grub_free((ptr)))
>> -#define yyrealloc(ptr, size, scanner) (grub_realloc((ptr), (size)))
>> -
>>  /*
>>   * As we don't have access to yyscanner, we cannot do much except to
>>   * print the fatal error.
>> @@ -327,6 +323,24 @@ POS_MULTILINE   {WORD}?\\\n
>>                  }
>>  %%
>>
>> +void *
>> +yyalloc(yy_size_t size, yyscan_t yyscanner)
>> +{
>>
> This is missing __attribute__ ((unused)) for second argument
> 
>> +  return grub_malloc(size);
>> +}
>> +
>> +void
>> +yyfree(void *ptr, yyscan_t yyscanner)
>> +{
>>
> Ditto
> 
>> +  return grub_free(ptr);
>> +}
>> +
>> +void *
>> +yyrealloc(void *ptr, yy_size_t size, yyscan_t yyscanner)
>> +{
>>
> Ditto
> 
>> +  return grub_realloc(ptr, size);
>> +}
>> +
>>  int
>>  yywrap (yyscan_t yyscanner)
>>  {
>> --
>> 2.12.0
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
>>
> 
> 
> 
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val
  2017-02-27  0:35   ` Vladimir 'phcoder' Serbinenko
@ 2017-02-27  5:54     ` Andrei Borzenkov
  2017-02-27 16:48       ` Steve Kenton
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-27  5:54 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: skenton

[-- Attachment #1: Type: text/plain, Size: 5154 bytes --]



Отправлено с iPhone

> 27 февр. 2017 г., в 3:35, Vladimir 'phcoder' Serbinenko <phcoder@gmail.com> написал(а):
> 
> 
> 
>> On Sun, Feb 26, 2017, 16:22 Nicholas Vinson <nvinson234@gmail.com> wrote:
>> From: Steve Kenton <address@hidden>
> 
> Please avoid resubmitting patches made by someone else in most cases. It obscures proper attribution. We can review his patch in his thread


In defense, the idea of consolidated patch series was mine, so blame me if you think it was wrong.


>> 
>> ---
>>  grub-core/commands/probe.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 59 insertions(+)
>> 
>> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
>> index cf2793e1d..5dd1a6bc5 100644
>> --- a/grub-core/commands/probe.c
>> +++ b/grub-core/commands/probe.c
>> @@ -16,6 +16,7 @@
>>   *  along with GRUB.  If not, see <http://www.gnu.org/licenses/>.
>>   */
>> 
>> +#include <stddef.h>
>>  #include <grub/types.h>
>>  #include <grub/misc.h>
>>  #include <grub/mm.h>
>> @@ -24,6 +25,8 @@
>>  #include <grub/device.h>
>>  #include <grub/disk.h>
>>  #include <grub/partition.h>
>> +#include <grub/gpt_partition.h>
>> +#include <grub/i386/pc/boot.h>
>>  #include <grub/net.h>
>>  #include <grub/fs.h>
>>  #include <grub/file.h>
>> @@ -45,6 +48,7 @@ static const struct grub_arg_option options[] =
>>      {"fs",             'f', 0, N_("Determine filesystem type."), 0, 0},
>>      {"fs-uuid",                'u', 0, N_("Determine filesystem UUID."), 0, 0},
>>      {"label",          'l', 0, N_("Determine filesystem label."), 0, 0},
>> +    {"partuuid",       'g', 0, N_("Determine partition GUID/UUID."), 0, 0}, /* GUID but Linux kernel calls it "PARTUUID" */
>>      {0, 0, 0, 0, 0, 0}
>>    };
>> 
>> @@ -154,6 +158,61 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args)
>>        grub_device_close (dev);
>>        return GRUB_ERR_NONE;
>>      }
>> +  if (state[6].set)
>> +    {
>> +      char *partuuid = NULL; /* NULL to silence a spurious GCC warning */
>> +      /* Nested partitions are not supported for now. */
>> +      /* Non-nested partitions must have dev->disk->partition->parent == NULL */
>> +      if (dev->disk && dev->disk->partition && dev->disk->partition->parent == NULL)
>> +       {
>> +        grub_partition_t p = dev->disk->partition;
>> +        if (grub_strcmp (p->partmap->name, "msdos") == 0)
>> +          {
>> +             /* little-endian 4-byte NT disk id "GUID" in the MBR */
>> +             grub_uint8_t diskid[4];
>> +            dev->disk->partition = p->parent;
>> +            grub_uint32_t nt_disk_sig;
>> +            err = grub_disk_read (dev->disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, sizeof(diskid), diskid);
>> +            dev->disk->partition = p;
>> +            if (err)
>> +              return grub_errno;
>> +            /* partition numbers are one-based */
>> +            partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
>> +                                       diskid[3], diskid[2], diskid[1], disk[0],
>> +                                       p->number + 1);
>> +          }
>> +        else if (grub_strcmp (p->partmap->name, "gpt") == 0)
>> +          {
>> +            struct grub_gpt_partentry e;
>> +            dev->disk->partition = p->parent;
>> +            err = grub_disk_read (dev->disk, p->offset, p->index, sizeof e, &e);
>> +            dev->disk->partition = p;
>> +            if (err)
>> +              return grub_errno;
>> +
>> +            partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
>> +                                       e.guid[3], e.guid[2], e.guid[1], e.guid[0],
>> +                                       e.guid[5], e.guid[4],
>> +                                       e.guid[7], e.guid[6],
>> +                                       e.guid[8], e.guid[9],
>> +                                       e.guid[10], e.guid[11], e.guid[12], e.guid[13], e.guid[14], e.guid[15]);
>> +          }
>> +        else
>> +          return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
>> +                             N_("partition map %s does not support partition UUIDs"),
>> +                             dev->disk->partition->partmap->name);
>> +       }
>> +      else
>> +       partuuid = grub_strdup (""); /* a freeable empty string */
>> +
>> +      if (state[0].set)
>> +       grub_env_set (state[0].arg, partuuid);
>> +      else
>> +       grub_printf ("%s", partuuid);
>> +      grub_free (partuuid);
>> +      grub_device_close (dev);
>> +      return GRUB_ERR_NONE;
>> +    }
>>    grub_device_close (dev);
>>    return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised target");
>>  }
>> --
>> 2.12.0
>> 
>> 
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel

[-- Attachment #2: Type: text/html, Size: 10781 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val
  2017-02-27  5:54     ` Andrei Borzenkov
@ 2017-02-27 16:48       ` Steve Kenton
  0 siblings, 0 replies; 14+ messages in thread
From: Steve Kenton @ 2017-02-27 16:48 UTC (permalink / raw)
  To: Andrei Borzenkov, The development of GNU GRUB

[-- Attachment #1: Type: text/plain, Size: 1341 bytes --]

On 02/27/2017 05:54 AM, Andrei Borzenkov wrote:

>
>
> Отправлено с iPhone
>
> 27 февр. 2017 г., в 3:35, Vladimir 'phcoder' Serbinenko 
> <phcoder@gmail.com <mailto:phcoder@gmail.com>> написал(а):
>
>>
>>
>> On Sun, Feb 26, 2017, 16:22 Nicholas Vinson <nvinson234@gmail.com 
>> <mailto:nvinson234@gmail.com>> wrote:
>>
>>     From: Steve Kenton <address@hidden>
>>
>> Please avoid resubmitting patches made by someone else in most cases. 
>> It obscures proper attribution. We can review his patch in his thread
>
>
> In defense, the idea of consolidated patch series was mine, so blame 
> me if you think it was wrong.
>
>
Yes, that is why Nick and I have been communicating/cooperating. I 
intentionally did not incorporate his changes (which I agree with and 
like btw) until I seemed to stop getting feedback after the nested 
partition changes. At that point I suggested he roll it into his patch 
set as Andrei requested. So, how to proceed? If you are unsure about 
nested partitions, I'm sure I am clueless :-) For what it's worth, I've 
been running with the --partuuid patches applied on the (shipping) 
embedded linux video system which started me working on this. Just 
trying to give something back to the community in the spirit of open source.

FYI - Steve Kenton


[-- Attachment #2: Type: text/html, Size: 2543 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 5/5] Harmonize patches
  2017-02-27  0:34   ` Vladimir 'phcoder' Serbinenko
@ 2017-02-27 18:03     ` Andrei Borzenkov
  0 siblings, 0 replies; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-27 18:03 UTC (permalink / raw)
  To: The development of GNU GRUB, skenton

27.02.2017 03:34, Vladimir 'phcoder' Serbinenko пишет:
>>    if (state[6].set)
>>      {
>>        char *partuuid = NULL; /* NULL to silence a spurious GCC warning */
>> -      /* Nested partitions are not supported for now. */
>> -      /* Non-nested partitions must have dev->disk->partition->parent ==
>> NULL */
>> -      if (dev->disk && dev->disk->partition &&
>> dev->disk->partition->parent == NULL)
>> +      /*
>> +       * Nested partitions are not supported for now.
>> +       * Non-nested partitions must have dev->disk->partition->parent ==
>> NULL
>> +       */
>>
> I'm not sure that this is enough. In presence of nested partitions Linux
> may shift extended partitions as well. I think we need to do tests with
> qemu and bsd-formatted partitions
> 

In my testing Linux never sees nested partitions (it never scans
partitions for nested partitions). For all I can tell this check has
been there at least since 2006 (I'm lacy to look beyond introduction of
block/ directory).


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support
  2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
                   ` (4 preceding siblings ...)
  2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 5/5] Harmonize patches Nicholas Vinson
@ 2017-05-09  3:22 ` Nick Vinson
  5 siblings, 0 replies; 14+ messages in thread
From: Nick Vinson @ 2017-05-09  3:22 UTC (permalink / raw)
  To: skenton, grub-devel


[-- Attachment #1.1: Type: text/plain, Size: 4383 bytes --]

I would like to remind grub-devel of this patch set.  Since the last
time I submitted this, Flex-2.6.4 has been released, so Part 1 of this
patch set can now be dropped.  Part 5 is optional and can be removed if
the development team does not approve of its changes.

Finally, this is the version that included Steve Kenton's work as
requested by Andrei Borzenkov.  Steve Kenton's work is Part #4.

If necessary, I can resubmit the patch set with parts 1 and 4 (and 5)
removed.

Please let me know how you would like me to proceed.

Thanks,
Nicholas Vinson

On 02/26/2017 04:20 PM, Nicholas Vinson wrote:
> Changes from Patch v2:
>     - Added flex-2.6.3 compatibility patch
> 
>     - Fixed a GPT partition read error
> 
>     - Added Steve Kenton's patch
> 
>     - Changed struct grub_part_gpt_type name to struct
>       grub_part_gpt_part_guid
> 
>     - Changed grub_part_gpt_type_t typedef name to grub_part_gpt_guid_t
> 
>     - Added sprint_gpt_guid to Steve Kenton's patch
> 
>     - Updated v1 and Steve Kenton's patch to use similar methods when
>       reading partition GUIDs.
> 
> Changes from Patch v1:
>     - Added GRUB_ENABLE_LINUX_PARTUUID variable description to grub.texi
> 
>     - Removed added gpt_part_guid copy logic from
>       grub_gpt_partition_map_iterate()
> 
>     - Removed added NT disk signature copy logic from
>       grub_partition_msdos_iterate()
> 
>     - Removed modifications to partition number increment logic
> 
>     - Removed added guid union definition.
> 
>     - Added GRUB_ENABLE_LINUX_PARTUUID to grub-mkconfig.in export list
> 
>     - Moved PRINT_GPT_PARTTYPE printing logic to print_gpt_guid()
>       function in grub-probe.c
> 
>     - Updated PRINT_GPT_PARTTYPE case to call print_gpt_guid() function
>       in grub-probe.c.
> 
>     - Created probe_partuuid() function in grub-probe.c
> 
>     - Updated print == PRINT_PARTUUID check logic in probe() to call
>       probe_partuuid().
> 
>     - Updated UUID logic in 10_linux.in to enable root=PARTUUID feature
>       only if GRUB_DISABLE_LINUX_UUID is not set to true,
>       and GRUB_DEVICE_PARTUUID is not empty, GRUB_ENABLE_LINUX_PARTUUID
>       is set to true.
> 
> Hello,
> 
> This is a request to add PARTUUID detection support grub-probe for MBR
> and GPT partition schemes.  The Linux kernel supports mounting the root
> filesystem by Linux device name or by the Partition [GU]UID.  GRUB's
> mkconfig, however, currently only supports specifying the rootfs in the
> kernel command-line by Linux device name unless an initramfs is also
> present.  When an initramfs is present GRUB's mkconfig will set the
> kernel's root parameter value to either the Linux device name or to the
> filesystem [GU]UID.
> 
> Therefore, the only way to protect a Linux system from failing to boot
> when its Linux storage device names change is to either manually edit
> grub.cfg or /etc/default/grub and append root=PARTUUID=xxx to the
> command-line or create an initramfs that understands how to mount
> devices by filesystem [G]UID and let grub-mkconfig pass the filesystem
> [GU]UID to the initramfs.
> 
> The goal of this patch set is to enable root=PARTUUID=xxx support in
> grub-mkconfig, so that users don't have to manually edit
> /etc/default/grub or grub.cfg, or create an initramfs for the sole
> purpose of having a robust bootloader configuration for Linux.
> 
> Thanks,
> Nicholas Vinson
> 
> Nicholas Vinson (4):
>   Fix flex-2.6.3 incompatbility issue
>   Add PARTUUID detection support to grub-probe
>   Update grub script template files
>   Harmonize patches
> 
> Steve Kenton (1):
>   Support both EFI and NT Disk Signature for passing to kernel as
>     root=PARTUUID=$val
> 
>  docs/grub.texi               | 13 +++++++
>  grub-core/commands/probe.c   | 78 ++++++++++++++++++++++++++++++++++++++++++
>  grub-core/disk/ldm.c         |  2 +-
>  grub-core/partmap/gpt.c      |  4 +--
>  grub-core/script/yylex.l     | 22 +++++++++---
>  include/grub/gpt_partition.h |  8 ++---
>  util/grub-install.c          |  2 +-
>  util/grub-mkconfig.in        |  3 ++
>  util/grub-probe.c            | 81 ++++++++++++++++++++++++++++++++++++--------
>  util/grub.d/10_linux.in      | 13 +++++--
>  10 files changed, 197 insertions(+), 29 deletions(-)
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2017-05-09  3:22 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-27  0:20 [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nicholas Vinson
2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 1/5] Fix flex-2.6.3 incompatbility issue Nicholas Vinson
2017-02-27  0:28   ` Vladimir 'phcoder' Serbinenko
2017-02-27  4:34     ` Andrei Borzenkov
2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 2/5] Add PARTUUID detection support to grub-probe Nicholas Vinson
2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 3/5] Update grub script template files Nicholas Vinson
2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 4/5] Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val Nicholas Vinson
2017-02-27  0:35   ` Vladimir 'phcoder' Serbinenko
2017-02-27  5:54     ` Andrei Borzenkov
2017-02-27 16:48       ` Steve Kenton
2017-02-27  0:20 ` [GRUB PARTUUID PATCH V3 5/5] Harmonize patches Nicholas Vinson
2017-02-27  0:34   ` Vladimir 'phcoder' Serbinenko
2017-02-27 18:03     ` Andrei Borzenkov
2017-05-09  3:22 ` [GRUB PARTUUID PATCH V3 0/5] Add PARTUUID detection support Nick Vinson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).