grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [GRUB PARTUUID PATCH V6 3/4] Add PARTUUID detection support to grub-


From: Daniel Kiper
Subject: Re: [GRUB PARTUUID PATCH V6 3/4] Add PARTUUID detection support to grub-probe
Date: Thu, 22 Mar 2018 14:51:20 +0100
User-agent: Mutt/1.3.28i

On Sun, Mar 18, 2018 at 12:06:02PM -0700, Nicholas Vinson wrote:
> Add PARTUUID detection support grub-probe for MBR and GPT partition
> schemes.
>
> Signed-off-by: Nicholas Vinson <address@hidden>
> ---
>  util/grub-probe.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 51 insertions(+)
>
> diff --git a/util/grub-probe.c b/util/grub-probe.c
> index 21cb80fbe..0ae73c591 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",
> @@ -181,6 +184,48 @@ probe_partmap (grub_disk_t disk, char delim)
>      }
>  }
>
> +static void
> +probe_partuuid (grub_disk_t disk, char delim)
> +{

Define p here:
  grub_partition_t p = disk->partition;

> +  /*
> +   * 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;

Somthing is wrong with formating here and there. Please fix this.

> +         grub_partition_t p = disk->partition;

Drop this...

> +         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;

...and above line...

> +     }
> +      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)
> +         print_gpt_guid(gptdata.guid);
> +
> +       disk->partition = p;

...and above line...

> +     }

...and add this here:
    disk->partition = p;

Daniel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]