All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] add --partuuid to probe
@ 2016-08-16 14:56 Steve Kenton
  0 siblings, 0 replies; 14+ messages in thread
From: Steve Kenton @ 2016-08-16 14:56 UTC (permalink / raw)
  To: grub-devel; +Cc: Steve Kenton

Supports both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val

Signed-off-by: Steve Kenton <skenton@ou.edu>
---
This passed light testing here, giving correct results for both types compared to blkid

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

diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
index cf2793e..0473d39 100644
--- a/grub-core/commands/probe.c
+++ b/grub-core/commands/probe.c
@@ -45,6 +45,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 UUID."), 0, 0}, /* 'g' for guid since 'u' was taken */
     {0, 0, 0, 0, 0, 0}
   };
 
@@ -154,6 +155,58 @@ 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 */
+      grub_uint8_t diskbuf[16];
+      if (dev->disk && dev->disk->partition)
+	{
+	  grub_partition_t p = dev->disk->partition;
+	  if (!grub_strcmp (p->partmap->name, "msdos"))
+	    {
+	      const int diskid_offset = 440; /* location in MBR */
+	      dev->disk->partition = p->parent;
+	      /* little-endian 4-byte NT disk signature */
+	      err = grub_disk_read (dev->disk, 0, diskid_offset, 4, diskbuf);
+	      dev->disk->partition = p;
+	      if (err)
+	        return grub_errno;
+	      partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
+					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
+					 p->number + 1); /* one based partition number */
+	    }
+	  else if (!grub_strcmp (p->partmap->name, "gpt"))
+	    {
+	      const int guid_offset = 16; /* location in entry */
+	      dev->disk->partition = p->parent;
+	      /* little-endian 16-byte EFI partition GUID */
+	      err = grub_disk_read (dev->disk, p->offset, p->index + guid_offset, 16, diskbuf);
+	      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",
+					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
+					 diskbuf[5], diskbuf[4],
+					 diskbuf[7], diskbuf[6],
+					 diskbuf[8], diskbuf[9],
+					 diskbuf[10], diskbuf[11], diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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.9.0.137.gcf4c2cf



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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-28  4:11               ` Andrei Borzenkov
@ 2017-02-28 14:08                 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 0 replies; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-28 14:08 UTC (permalink / raw)
  To: The development of GNU GRUB

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

On Mon, Feb 27, 2017, 20:11 Andrei Borzenkov <arvidjaar@gmail.com> wrote:

> 27.02.2017 21:20, Vladimir 'phcoder' Serbinenko пишет:
> > On Mon, Feb 27, 2017, 09:55 Andrei Borzenkov <arvidjaar@gmail.com>
> wrote:
> >
> >> 27.02.2017 03:37, Vladimir 'phcoder' Serbinenko пишет:
> >> ...
> >>>>>>> This is not NT-style. NT uses partition offset. Who uses this
> format?
> >>>> Are
> >>>>>>
> >>>>>> This is used by util-linux and Linux kernel.
> >>>>>>
> >>>>>>
> >>>>>>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF
> representing
> >>>> the
> >>>>>>  *         unique id of a partition if the partition table provides
> >> it.
> >>>>>>  *         The UUID may be either an EFI/GPT UUID, or refer to an
> >> MSDOS
> >>>>>>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS
> is a
> >>>>>> zero-
> >>>>>>  *         filled hex representation of the 32-bit "NT disk
> >> signature",
> >>>>>> and PP
> >>>>>>  *         is a zero-filled hex representation of the 1-based
> >> partition
> >>>>>> number.
> >>>>>>
> >>>>>>> you sure that partition numbers are synced with user? Even in
> >> presence
> >>>> of
> >>>>>>> Solaris and bsd partitions.
> >>>>>>>
> >>>>>>
> >>>>>> It is not clear what we should return for nested partition. I'm not
> >> sure
> >>>>>> whether linux kernel scans nested partitions at all in which case we
> >>>>>> probably should follow the suite and assign PARTUUID to top-level
> >>>>>> partitions only.
> >>>>>>
> >>>>> Linux scans nested partitions and it uses though numeration in
> >> dev/sdaX,
> >>>> in
> >>>>> some cases shifting numbering of normal partitions. In those cases
> grub
> >>>> and
> >>>>> Linux numeration get out of sync
> >>>>>
> >>>>
> >>>> Can you provide example?
> >>>
> >>> Bsd and Solaris partitions. I remember we had problem with numbering of
> >>> those.
> >>>
> >>
> >> Linux ignores nested BSD partitions (just tested). There are no special
> >> files created. Of course someone needs to test what happens under
> >> *BSD/Solaris in this case.
> >>
> > Kpartx or normal sdX? Is bsd-partition support enabled in kernel build?
> >
>
> OK I see, kernel skips BSD partition marked as "unused".
>
> So it appears that kernel always puts special nested partitions after
> normal logical MSDOS partitions, so it will not skew MSDOS partition
> numbers.
>
> [    1.529752]  vda: vda1 vda2 vda3 < vda5 vda6 >
>                 vda2: <openbsd: vda7 >
>
>
>         /*
>          * Look for partitions in two passes:
>          * First find the primary and DOS-type extended partitions.
>          * On the second pass look inside *BSD, Unixware and Solaris
> partitions.
>          */
>
> For such partition (vda7) PARTUUID is empty.
>
> P.S. I wonder whether we correctly map such partition ... no, we do not.
>
> 10:~ # cat /tmp/foo
> (hd0) /dev/vda
> 10:~ # grub2-probe -m /tmp/foo -t compatibility_hint -d /dev/vda2
> hd0,msdos2
> 10:~ # grub2-probe -m /tmp/foo -t compatibility_hint -d /dev/vda5
> hd0,msdos5
> 10:~ # grub2-probe -m /tmp/foo -t compatibility_hint -d /dev/vda7
> hd0,msdos2
>
WAI. In case when subpartition starts at the same sector as partition
itself.

>
>
> >>
> >> I never liked idea of artificial partition GUIDs for MBR, but as long as
> >> only Linux is using them and we are consistent with its usage - so be
> it.
> >>
> >>>> I tried to create nested partition table, but
> >>>> Linux will not display it (actually attempt to "blockdev --rereadpt
> >>>> /dev/vda5" fails with "Invalid argument").
> >>>>
> >>>>         if (!disk_part_scan_enabled(disk) || bdev !=
> bdev->bd_contains)
> >>>>                 return -EINVAL;
> >>>>
> >>>> Where bdev->bd_contains points to containing device for partition and
> to
> >>>> itself for the whole disk.
> >>>>
> >>>> As util-linux does not scan partition table itself, it does show these
> >>>> nested partitions either.
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

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

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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-27 18:20             ` Vladimir 'phcoder' Serbinenko
@ 2017-02-28  4:11               ` Andrei Borzenkov
  2017-02-28 14:08                 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-28  4:11 UTC (permalink / raw)
  To: grub-devel

27.02.2017 21:20, Vladimir 'phcoder' Serbinenko пишет:
> On Mon, Feb 27, 2017, 09:55 Andrei Borzenkov <arvidjaar@gmail.com> wrote:
> 
>> 27.02.2017 03:37, Vladimir 'phcoder' Serbinenko пишет:
>> ...
>>>>>>> This is not NT-style. NT uses partition offset. Who uses this format?
>>>> Are
>>>>>>
>>>>>> This is used by util-linux and Linux kernel.
>>>>>>
>>>>>>
>>>>>>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing
>>>> the
>>>>>>  *         unique id of a partition if the partition table provides
>> it.
>>>>>>  *         The UUID may be either an EFI/GPT UUID, or refer to an
>> MSDOS
>>>>>>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a
>>>>>> zero-
>>>>>>  *         filled hex representation of the 32-bit "NT disk
>> signature",
>>>>>> and PP
>>>>>>  *         is a zero-filled hex representation of the 1-based
>> partition
>>>>>> number.
>>>>>>
>>>>>>> you sure that partition numbers are synced with user? Even in
>> presence
>>>> of
>>>>>>> Solaris and bsd partitions.
>>>>>>>
>>>>>>
>>>>>> It is not clear what we should return for nested partition. I'm not
>> sure
>>>>>> whether linux kernel scans nested partitions at all in which case we
>>>>>> probably should follow the suite and assign PARTUUID to top-level
>>>>>> partitions only.
>>>>>>
>>>>> Linux scans nested partitions and it uses though numeration in
>> dev/sdaX,
>>>> in
>>>>> some cases shifting numbering of normal partitions. In those cases grub
>>>> and
>>>>> Linux numeration get out of sync
>>>>>
>>>>
>>>> Can you provide example?
>>>
>>> Bsd and Solaris partitions. I remember we had problem with numbering of
>>> those.
>>>
>>
>> Linux ignores nested BSD partitions (just tested). There are no special
>> files created. Of course someone needs to test what happens under
>> *BSD/Solaris in this case.
>>
> Kpartx or normal sdX? Is bsd-partition support enabled in kernel build?
> 

OK I see, kernel skips BSD partition marked as "unused".

So it appears that kernel always puts special nested partitions after
normal logical MSDOS partitions, so it will not skew MSDOS partition
numbers.

[    1.529752]  vda: vda1 vda2 vda3 < vda5 vda6 >
                vda2: <openbsd: vda7 >


        /*
         * Look for partitions in two passes:
         * First find the primary and DOS-type extended partitions.
         * On the second pass look inside *BSD, Unixware and Solaris
partitions.
         */

For such partition (vda7) PARTUUID is empty.

P.S. I wonder whether we correctly map such partition ... no, we do not.

10:~ # cat /tmp/foo
(hd0) /dev/vda
10:~ # grub2-probe -m /tmp/foo -t compatibility_hint -d /dev/vda2
hd0,msdos2
10:~ # grub2-probe -m /tmp/foo -t compatibility_hint -d /dev/vda5
hd0,msdos5
10:~ # grub2-probe -m /tmp/foo -t compatibility_hint -d /dev/vda7
hd0,msdos2


>>
>> I never liked idea of artificial partition GUIDs for MBR, but as long as
>> only Linux is using them and we are consistent with its usage - so be it.
>>
>>>> I tried to create nested partition table, but
>>>> Linux will not display it (actually attempt to "blockdev --rereadpt
>>>> /dev/vda5" fails with "Invalid argument").
>>>>
>>>>         if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
>>>>                 return -EINVAL;
>>>>
>>>> Where bdev->bd_contains points to containing device for partition and to
>>>> itself for the whole disk.
>>>>
>>>> As util-linux does not scan partition table itself, it does show these
>>>> nested partitions either.



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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-27 17:53           ` Andrei Borzenkov
@ 2017-02-27 18:20             ` Vladimir 'phcoder' Serbinenko
  2017-02-28  4:11               ` Andrei Borzenkov
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-27 18:20 UTC (permalink / raw)
  To: The development of GNU GRUB

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

On Mon, Feb 27, 2017, 09:55 Andrei Borzenkov <arvidjaar@gmail.com> wrote:

> 27.02.2017 03:37, Vladimir 'phcoder' Serbinenko пишет:
> ...
> >>>>> This is not NT-style. NT uses partition offset. Who uses this format?
> >> Are
> >>>>
> >>>> This is used by util-linux and Linux kernel.
> >>>>
> >>>>
> >>>>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing
> >> the
> >>>>  *         unique id of a partition if the partition table provides
> it.
> >>>>  *         The UUID may be either an EFI/GPT UUID, or refer to an
> MSDOS
> >>>>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a
> >>>> zero-
> >>>>  *         filled hex representation of the 32-bit "NT disk
> signature",
> >>>> and PP
> >>>>  *         is a zero-filled hex representation of the 1-based
> partition
> >>>> number.
> >>>>
> >>>>> you sure that partition numbers are synced with user? Even in
> presence
> >> of
> >>>>> Solaris and bsd partitions.
> >>>>>
> >>>>
> >>>> It is not clear what we should return for nested partition. I'm not
> sure
> >>>> whether linux kernel scans nested partitions at all in which case we
> >>>> probably should follow the suite and assign PARTUUID to top-level
> >>>> partitions only.
> >>>>
> >>> Linux scans nested partitions and it uses though numeration in
> dev/sdaX,
> >> in
> >>> some cases shifting numbering of normal partitions. In those cases grub
> >> and
> >>> Linux numeration get out of sync
> >>>
> >>
> >> Can you provide example?
> >
> > Bsd and Solaris partitions. I remember we had problem with numbering of
> > those.
> >
>
> Linux ignores nested BSD partitions (just tested). There are no special
> files created. Of course someone needs to test what happens under
> *BSD/Solaris in this case.
>
Kpartx or normal sdX? Is bsd-partition support enabled in kernel build?

>
> I never liked idea of artificial partition GUIDs for MBR, but as long as
> only Linux is using them and we are consistent with its usage - so be it.
>
> >> I tried to create nested partition table, but
> >> Linux will not display it (actually attempt to "blockdev --rereadpt
> >> /dev/vda5" fails with "Invalid argument").
> >>
> >>         if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
> >>                 return -EINVAL;
> >>
> >> Where bdev->bd_contains points to containing device for partition and to
> >> itself for the whole disk.
> >>
> >> As util-linux does not scan partition table itself, it does show these
> >> nested partitions either.
> >>
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

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

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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-27  0:37         ` Vladimir 'phcoder' Serbinenko
@ 2017-02-27 17:53           ` Andrei Borzenkov
  2017-02-27 18:20             ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-27 17:53 UTC (permalink / raw)
  To: grub-devel

27.02.2017 03:37, Vladimir 'phcoder' Serbinenko пишет:
...
>>>>> This is not NT-style. NT uses partition offset. Who uses this format?
>> Are
>>>>
>>>> This is used by util-linux and Linux kernel.
>>>>
>>>>
>>>>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing
>> the
>>>>  *         unique id of a partition if the partition table provides it.
>>>>  *         The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
>>>>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a
>>>> zero-
>>>>  *         filled hex representation of the 32-bit "NT disk signature",
>>>> and PP
>>>>  *         is a zero-filled hex representation of the 1-based partition
>>>> number.
>>>>
>>>>> you sure that partition numbers are synced with user? Even in presence
>> of
>>>>> Solaris and bsd partitions.
>>>>>
>>>>
>>>> It is not clear what we should return for nested partition. I'm not sure
>>>> whether linux kernel scans nested partitions at all in which case we
>>>> probably should follow the suite and assign PARTUUID to top-level
>>>> partitions only.
>>>>
>>> Linux scans nested partitions and it uses though numeration in dev/sdaX,
>> in
>>> some cases shifting numbering of normal partitions. In those cases grub
>> and
>>> Linux numeration get out of sync
>>>
>>
>> Can you provide example?
> 
> Bsd and Solaris partitions. I remember we had problem with numbering of
> those.
> 

Linux ignores nested BSD partitions (just tested). There are no special
files created. Of course someone needs to test what happens under
*BSD/Solaris in this case.

I never liked idea of artificial partition GUIDs for MBR, but as long as
only Linux is using them and we are consistent with its usage - so be it.

>> I tried to create nested partition table, but
>> Linux will not display it (actually attempt to "blockdev --rereadpt
>> /dev/vda5" fails with "Invalid argument").
>>
>>         if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
>>                 return -EINVAL;
>>
>> Where bdev->bd_contains points to containing device for partition and to
>> itself for the whole disk.
>>
>> As util-linux does not scan partition table itself, it does show these
>> nested partitions either.
>>



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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-19  6:12       ` Andrei Borzenkov
@ 2017-02-27  0:37         ` Vladimir 'phcoder' Serbinenko
  2017-02-27 17:53           ` Andrei Borzenkov
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-27  0:37 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Steve Kenton

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

On Sat, Feb 18, 2017, 22:13 Andrei Borzenkov <arvidjaar@gmail.com> wrote:

> 15.02.2017 20:25, Vladimir 'phcoder' Serbinenko пишет:
> > On Wed, Feb 15, 2017, 17:27 Andrei Borzenkov <arvidjaar@gmail.com>
> wrote:
> >
> >> 15.02.2017 13:56, Vladimir 'phcoder' Serbinenko пишет:
> >>> On Tue, Feb 14, 2017, 19:01 Steve Kenton <skenton@ou.edu> wrote:
> >>>
> >>>> Support both EFI and NT Disk Signature for passing to kernel as
> >>>> root=PARTUUID=$val
> >>>>
> >>>> Signed-off-by: Steve Kenton <skenton@ou.edu>
> >>>> ---
> >>>> It's been six months so I thought I'd resend this so it does not get
> >> lost
> >>>> in case I get hit by a meteor or something before the next release
> >>>>
> >>>>  grub-core/commands/probe.c | 53
> >>>> ++++++++++++++++++++++++++++++++++++++++++++++
> >>>>  1 file changed, 53 insertions(+)
> >>>>
> >>>> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> >>>> index cf2793e..3afc8b8 100644
> >>>> --- a/grub-core/commands/probe.c
> >>>> +++ b/grub-core/commands/probe.c
> >>>> @@ -45,6 +45,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" */
> >>>>
> >>> I like how it generalizes.
> >>>
> >>>>      {0, 0, 0, 0, 0, 0}
> >>>>    };
> >>>>
> >>>> @@ -154,6 +155,58 @@ 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
> >> */
> >>>> +      grub_uint8_t diskbuf[16];
> >>>> +      if (dev->disk && dev->disk->partition)
> >>>> +       {
> >>>> +         grub_partition_t p = dev->disk->partition;
> >>>> +         if (!grub_strcmp (p->partmap->name, "msdos"))
> >>>>
> >>> Please use == 0 rather than !
> >>>
> >>>> +           {
> >>>> +             const int diskid_offset = 440; /* location in MBR */
> >>>>
> >>> Please get this from a common header rather than hard coding. I think
> we
> >>> have it in msdos.h
> >>>
> >>>> +             dev->disk->partition = p->parent;
> >>>> +             /* little-endian 4-byte NT disk signature */
> >>>> +             err = grub_disk_read (dev->disk, 0, diskid_offset, 4,
> >>>> diskbuf);
> >>>> +             dev->disk->partition = p;
> >>>> +             if (err)
> >>>> +               return grub_errno;
> >>>> +             partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
> >>>> +                                        diskbuf[3], diskbuf[2],
> >>>> diskbuf[1], diskbuf[0],
> >>>> +                                        p->number + 1); /* one based
> >>>> partition number */
> >>>>
> >>> This is not NT-style. NT uses partition offset. Who uses this format?
> Are
> >>
> >> This is used by util-linux and Linux kernel.
> >>
> >>
> >>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing
> the
> >>  *         unique id of a partition if the partition table provides it.
> >>  *         The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
> >>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a
> >> zero-
> >>  *         filled hex representation of the 32-bit "NT disk signature",
> >> and PP
> >>  *         is a zero-filled hex representation of the 1-based partition
> >> number.
> >>
> >>> you sure that partition numbers are synced with user? Even in presence
> of
> >>> Solaris and bsd partitions.
> >>>
> >>
> >> It is not clear what we should return for nested partition. I'm not sure
> >> whether linux kernel scans nested partitions at all in which case we
> >> probably should follow the suite and assign PARTUUID to top-level
> >> partitions only.
> >>
> > Linux scans nested partitions and it uses though numeration in dev/sdaX,
> in
> > some cases shifting numbering of normal partitions. In those cases grub
> and
> > Linux numeration get out of sync
> >
>
> Can you provide example?

Bsd and Solaris partitions. I remember we had problem with numbering of
those.

> I tried to create nested partition table, but
> Linux will not display it (actually attempt to "blockdev --rereadpt
> /dev/vda5" fails with "Invalid argument").
>
>         if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
>                 return -EINVAL;
>
> Where bdev->bd_contains points to containing device for partition and to
> itself for the whole disk.
>
> As util-linux does not scan partition table itself, it does show these
> nested partitions either.
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

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

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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-15 17:25     ` Vladimir 'phcoder' Serbinenko
@ 2017-02-19  6:12       ` Andrei Borzenkov
  2017-02-27  0:37         ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-19  6:12 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Steve Kenton

15.02.2017 20:25, Vladimir 'phcoder' Serbinenko пишет:
> On Wed, Feb 15, 2017, 17:27 Andrei Borzenkov <arvidjaar@gmail.com> wrote:
> 
>> 15.02.2017 13:56, Vladimir 'phcoder' Serbinenko пишет:
>>> On Tue, Feb 14, 2017, 19:01 Steve Kenton <skenton@ou.edu> wrote:
>>>
>>>> Support both EFI and NT Disk Signature for passing to kernel as
>>>> root=PARTUUID=$val
>>>>
>>>> Signed-off-by: Steve Kenton <skenton@ou.edu>
>>>> ---
>>>> It's been six months so I thought I'd resend this so it does not get
>> lost
>>>> in case I get hit by a meteor or something before the next release
>>>>
>>>>  grub-core/commands/probe.c | 53
>>>> ++++++++++++++++++++++++++++++++++++++++++++++
>>>>  1 file changed, 53 insertions(+)
>>>>
>>>> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
>>>> index cf2793e..3afc8b8 100644
>>>> --- a/grub-core/commands/probe.c
>>>> +++ b/grub-core/commands/probe.c
>>>> @@ -45,6 +45,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" */
>>>>
>>> I like how it generalizes.
>>>
>>>>      {0, 0, 0, 0, 0, 0}
>>>>    };
>>>>
>>>> @@ -154,6 +155,58 @@ 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
>> */
>>>> +      grub_uint8_t diskbuf[16];
>>>> +      if (dev->disk && dev->disk->partition)
>>>> +       {
>>>> +         grub_partition_t p = dev->disk->partition;
>>>> +         if (!grub_strcmp (p->partmap->name, "msdos"))
>>>>
>>> Please use == 0 rather than !
>>>
>>>> +           {
>>>> +             const int diskid_offset = 440; /* location in MBR */
>>>>
>>> Please get this from a common header rather than hard coding. I think we
>>> have it in msdos.h
>>>
>>>> +             dev->disk->partition = p->parent;
>>>> +             /* little-endian 4-byte NT disk signature */
>>>> +             err = grub_disk_read (dev->disk, 0, diskid_offset, 4,
>>>> diskbuf);
>>>> +             dev->disk->partition = p;
>>>> +             if (err)
>>>> +               return grub_errno;
>>>> +             partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
>>>> +                                        diskbuf[3], diskbuf[2],
>>>> diskbuf[1], diskbuf[0],
>>>> +                                        p->number + 1); /* one based
>>>> partition number */
>>>>
>>> This is not NT-style. NT uses partition offset. Who uses this format? Are
>>
>> This is used by util-linux and Linux kernel.
>>
>>
>>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the
>>  *         unique id of a partition if the partition table provides it.
>>  *         The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
>>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a
>> zero-
>>  *         filled hex representation of the 32-bit "NT disk signature",
>> and PP
>>  *         is a zero-filled hex representation of the 1-based partition
>> number.
>>
>>> you sure that partition numbers are synced with user? Even in presence of
>>> Solaris and bsd partitions.
>>>
>>
>> It is not clear what we should return for nested partition. I'm not sure
>> whether linux kernel scans nested partitions at all in which case we
>> probably should follow the suite and assign PARTUUID to top-level
>> partitions only.
>>
> Linux scans nested partitions and it uses though numeration in dev/sdaX, in
> some cases shifting numbering of normal partitions. In those cases grub and
> Linux numeration get out of sync
> 

Can you provide example? I tried to create nested partition table, but
Linux will not display it (actually attempt to "blockdev --rereadpt
/dev/vda5" fails with "Invalid argument").

        if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
                return -EINVAL;

Where bdev->bd_contains points to containing device for partition and to
itself for the whole disk.

As util-linux does not scan partition table itself, it does show these
nested partitions either.


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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-15 16:26   ` Andrei Borzenkov
@ 2017-02-15 17:25     ` Vladimir 'phcoder' Serbinenko
  2017-02-19  6:12       ` Andrei Borzenkov
  0 siblings, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-15 17:25 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Steve Kenton

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

On Wed, Feb 15, 2017, 17:27 Andrei Borzenkov <arvidjaar@gmail.com> wrote:

> 15.02.2017 13:56, Vladimir 'phcoder' Serbinenko пишет:
> > On Tue, Feb 14, 2017, 19:01 Steve Kenton <skenton@ou.edu> wrote:
> >
> >> Support both EFI and NT Disk Signature for passing to kernel as
> >> root=PARTUUID=$val
> >>
> >> Signed-off-by: Steve Kenton <skenton@ou.edu>
> >> ---
> >> It's been six months so I thought I'd resend this so it does not get
> lost
> >> in case I get hit by a meteor or something before the next release
> >>
> >>  grub-core/commands/probe.c | 53
> >> ++++++++++++++++++++++++++++++++++++++++++++++
> >>  1 file changed, 53 insertions(+)
> >>
> >> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> >> index cf2793e..3afc8b8 100644
> >> --- a/grub-core/commands/probe.c
> >> +++ b/grub-core/commands/probe.c
> >> @@ -45,6 +45,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" */
> >>
> > I like how it generalizes.
> >
> >>      {0, 0, 0, 0, 0, 0}
> >>    };
> >>
> >> @@ -154,6 +155,58 @@ 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
> */
> >> +      grub_uint8_t diskbuf[16];
> >> +      if (dev->disk && dev->disk->partition)
> >> +       {
> >> +         grub_partition_t p = dev->disk->partition;
> >> +         if (!grub_strcmp (p->partmap->name, "msdos"))
> >>
> > Please use == 0 rather than !
> >
> >> +           {
> >> +             const int diskid_offset = 440; /* location in MBR */
> >>
> > Please get this from a common header rather than hard coding. I think we
> > have it in msdos.h
> >
> >> +             dev->disk->partition = p->parent;
> >> +             /* little-endian 4-byte NT disk signature */
> >> +             err = grub_disk_read (dev->disk, 0, diskid_offset, 4,
> >> diskbuf);
> >> +             dev->disk->partition = p;
> >> +             if (err)
> >> +               return grub_errno;
> >> +             partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
> >> +                                        diskbuf[3], diskbuf[2],
> >> diskbuf[1], diskbuf[0],
> >> +                                        p->number + 1); /* one based
> >> partition number */
> >>
> > This is not NT-style. NT uses partition offset. Who uses this format? Are
>
> This is used by util-linux and Linux kernel.
>
>
>  *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the
>  *         unique id of a partition if the partition table provides it.
>  *         The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
>  *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a
> zero-
>  *         filled hex representation of the 32-bit "NT disk signature",
> and PP
>  *         is a zero-filled hex representation of the 1-based partition
> number.
>
> > you sure that partition numbers are synced with user? Even in presence of
> > Solaris and bsd partitions.
> >
>
> It is not clear what we should return for nested partition. I'm not sure
> whether linux kernel scans nested partitions at all in which case we
> probably should follow the suite and assign PARTUUID to top-level
> partitions only.
>
Linux scans nested partitions and it uses though numeration in dev/sdaX, in
some cases shifting numbering of normal partitions. In those cases grub and
Linux numeration get out of sync

>
> >> +           }
> >> +         else if (!grub_strcmp (p->partmap->name, "gpt"))
> >>
> > Ditto.
> >
> >> +           {
> >> +             const int guid_offset = 16; /* location in entry */
> >>
> > Ditto.
> >
> >> +             dev->disk->partition = p->parent;
> >> +             /* little-endian 16-byte EFI partition GUID */
> >> +             err = grub_disk_read (dev->disk, p->offset, p->index +
> >> guid_offset, 16, diskbuf);
> >> +             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",
> >> +                                        diskbuf[3], diskbuf[2],
> >> diskbuf[1], diskbuf[0],
> >> +                                        diskbuf[5], diskbuf[4],
> >> +                                        diskbuf[7], diskbuf[6],
> >> +                                        diskbuf[8], diskbuf[9],
> >> +                                        diskbuf[10], diskbuf[11],
> >> diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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.9.0.137.gcf4c2cf
> >>
> >>
> >> _______________________________________________
> >> 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
> >
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

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

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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-15 10:56 ` Vladimir 'phcoder' Serbinenko
@ 2017-02-15 16:26   ` Andrei Borzenkov
  2017-02-15 17:25     ` Vladimir 'phcoder' Serbinenko
  0 siblings, 1 reply; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-15 16:26 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Steve Kenton

15.02.2017 13:56, Vladimir 'phcoder' Serbinenko пишет:
> On Tue, Feb 14, 2017, 19:01 Steve Kenton <skenton@ou.edu> wrote:
> 
>> Support both EFI and NT Disk Signature for passing to kernel as
>> root=PARTUUID=$val
>>
>> Signed-off-by: Steve Kenton <skenton@ou.edu>
>> ---
>> It's been six months so I thought I'd resend this so it does not get lost
>> in case I get hit by a meteor or something before the next release
>>
>>  grub-core/commands/probe.c | 53
>> ++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 53 insertions(+)
>>
>> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
>> index cf2793e..3afc8b8 100644
>> --- a/grub-core/commands/probe.c
>> +++ b/grub-core/commands/probe.c
>> @@ -45,6 +45,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" */
>>
> I like how it generalizes.
> 
>>      {0, 0, 0, 0, 0, 0}
>>    };
>>
>> @@ -154,6 +155,58 @@ 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 */
>> +      grub_uint8_t diskbuf[16];
>> +      if (dev->disk && dev->disk->partition)
>> +       {
>> +         grub_partition_t p = dev->disk->partition;
>> +         if (!grub_strcmp (p->partmap->name, "msdos"))
>>
> Please use == 0 rather than !
> 
>> +           {
>> +             const int diskid_offset = 440; /* location in MBR */
>>
> Please get this from a common header rather than hard coding. I think we
> have it in msdos.h
> 
>> +             dev->disk->partition = p->parent;
>> +             /* little-endian 4-byte NT disk signature */
>> +             err = grub_disk_read (dev->disk, 0, diskid_offset, 4,
>> diskbuf);
>> +             dev->disk->partition = p;
>> +             if (err)
>> +               return grub_errno;
>> +             partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
>> +                                        diskbuf[3], diskbuf[2],
>> diskbuf[1], diskbuf[0],
>> +                                        p->number + 1); /* one based
>> partition number */
>>
> This is not NT-style. NT uses partition offset. Who uses this format? Are

This is used by util-linux and Linux kernel.


 *      6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the
 *         unique id of a partition if the partition table provides it.
 *         The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
 *         partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero-
 *         filled hex representation of the 32-bit "NT disk signature",
and PP
 *         is a zero-filled hex representation of the 1-based partition
number.

> you sure that partition numbers are synced with user? Even in presence of
> Solaris and bsd partitions.
> 

It is not clear what we should return for nested partition. I'm not sure
whether linux kernel scans nested partitions at all in which case we
probably should follow the suite and assign PARTUUID to top-level
partitions only.

>> +           }
>> +         else if (!grub_strcmp (p->partmap->name, "gpt"))
>>
> Ditto.
> 
>> +           {
>> +             const int guid_offset = 16; /* location in entry */
>>
> Ditto.
> 
>> +             dev->disk->partition = p->parent;
>> +             /* little-endian 16-byte EFI partition GUID */
>> +             err = grub_disk_read (dev->disk, p->offset, p->index +
>> guid_offset, 16, diskbuf);
>> +             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",
>> +                                        diskbuf[3], diskbuf[2],
>> diskbuf[1], diskbuf[0],
>> +                                        diskbuf[5], diskbuf[4],
>> +                                        diskbuf[7], diskbuf[6],
>> +                                        diskbuf[8], diskbuf[9],
>> +                                        diskbuf[10], diskbuf[11],
>> diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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.9.0.137.gcf4c2cf
>>
>>
>> _______________________________________________
>> 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: [PATCH 1/1] add --partuuid to probe
  2017-02-14 18:00 Steve Kenton
  2017-02-14 19:12 ` Andrei Borzenkov
@ 2017-02-15 10:56 ` Vladimir 'phcoder' Serbinenko
  2017-02-15 16:26   ` Andrei Borzenkov
  1 sibling, 1 reply; 14+ messages in thread
From: Vladimir 'phcoder' Serbinenko @ 2017-02-15 10:56 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Steve Kenton

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

On Tue, Feb 14, 2017, 19:01 Steve Kenton <skenton@ou.edu> wrote:

> Support both EFI and NT Disk Signature for passing to kernel as
> root=PARTUUID=$val
>
> Signed-off-by: Steve Kenton <skenton@ou.edu>
> ---
> It's been six months so I thought I'd resend this so it does not get lost
> in case I get hit by a meteor or something before the next release
>
>  grub-core/commands/probe.c | 53
> ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
>
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index cf2793e..3afc8b8 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c
> @@ -45,6 +45,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" */
>
I like how it generalizes.

>      {0, 0, 0, 0, 0, 0}
>    };
>
> @@ -154,6 +155,58 @@ 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 */
> +      grub_uint8_t diskbuf[16];
> +      if (dev->disk && dev->disk->partition)
> +       {
> +         grub_partition_t p = dev->disk->partition;
> +         if (!grub_strcmp (p->partmap->name, "msdos"))
>
Please use == 0 rather than !

> +           {
> +             const int diskid_offset = 440; /* location in MBR */
>
Please get this from a common header rather than hard coding. I think we
have it in msdos.h

> +             dev->disk->partition = p->parent;
> +             /* little-endian 4-byte NT disk signature */
> +             err = grub_disk_read (dev->disk, 0, diskid_offset, 4,
> diskbuf);
> +             dev->disk->partition = p;
> +             if (err)
> +               return grub_errno;
> +             partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
> +                                        diskbuf[3], diskbuf[2],
> diskbuf[1], diskbuf[0],
> +                                        p->number + 1); /* one based
> partition number */
>
This is not NT-style. NT uses partition offset. Who uses this format? Are
you sure that partition numbers are synced with user? Even in presence of
Solaris and bsd partitions.

> +           }
> +         else if (!grub_strcmp (p->partmap->name, "gpt"))
>
Ditto.

> +           {
> +             const int guid_offset = 16; /* location in entry */
>
Ditto.

> +             dev->disk->partition = p->parent;
> +             /* little-endian 16-byte EFI partition GUID */
> +             err = grub_disk_read (dev->disk, p->offset, p->index +
> guid_offset, 16, diskbuf);
> +             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",
> +                                        diskbuf[3], diskbuf[2],
> diskbuf[1], diskbuf[0],
> +                                        diskbuf[5], diskbuf[4],
> +                                        diskbuf[7], diskbuf[6],
> +                                        diskbuf[8], diskbuf[9],
> +                                        diskbuf[10], diskbuf[11],
> diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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.9.0.137.gcf4c2cf
>
>
> _______________________________________________
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel
>

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

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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-14 19:39   ` Steve Kenton
@ 2017-02-15  3:36     ` Nick Vinson
  0 siblings, 0 replies; 14+ messages in thread
From: Nick Vinson @ 2017-02-15  3:36 UTC (permalink / raw)
  To: Steve Kenton, Andrei Borzenkov, The development of GNU GRUB


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

I'll need to check it against the 2.02 sources, but even if it needs
updating, it shouldn't be too hard to do it.  I can add your changes to
the patchset.

-Nick

On 02/14/2017 11:39 AM, Steve Kenton wrote:
> Nick,
> 
> What is the state of your patch set? I think mine is much smaller if you
> want to roll it into yours and resubmit. We were told all along to wait
> until after 2.02, which should to be very soon, so it looks like it's
> show time!
> 
> Steve Kenton
> 
> 
> On 02/14/2017 07:12 PM, Andrei Borzenkov wrote:
>> 14.02.2017 21:00, Steve Kenton пишет:
>>> Support both EFI and NT Disk Signature for passing to kernel as
>>> root=PARTUUID=$val
>>>
>> Yes, I guess we need to add it finally. Unfortunately it is too late for
>> 2.02, but it should go after in release. There were also patches for
>> grub-probe and we also need to support it in search to be on par with
>> filesystem UUID. May be if you could prepare consolidated patch set it
>> would be great.
>>
>> I apologize that it tool so long. Thank you for not giving up!
>>
>>> Signed-off-by: Steve Kenton <skenton@ou.edu>
>>> ---
>>> It's been six months so I thought I'd resend this so it does not get
>>> lost
>>> in case I get hit by a meteor or something before the next release
>>>
>>>   grub-core/commands/probe.c | 53
>>> ++++++++++++++++++++++++++++++++++++++++++++++
>>>   1 file changed, 53 insertions(+)
>>>
>>> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
>>> index cf2793e..3afc8b8 100644
>>> --- a/grub-core/commands/probe.c
>>> +++ b/grub-core/commands/probe.c
>> Please also add patch for manual.
>>
>>> @@ -45,6 +45,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 +155,58 @@ 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 */
>>> +      grub_uint8_t diskbuf[16];
>>> +      if (dev->disk && dev->disk->partition)
>>> +    {
>>> +      grub_partition_t p = dev->disk->partition;
>>> +      if (!grub_strcmp (p->partmap->name, "msdos"))
>>> +        {
>>> +          const int diskid_offset = 440; /* location in MBR */
>>> +          dev->disk->partition = p->parent;
>>> +          /* little-endian 4-byte NT disk signature */
>>> +          err = grub_disk_read (dev->disk, 0, diskid_offset, 4,
>>> diskbuf);
>>> +          dev->disk->partition = p;
>>> +          if (err)
>>> +            return grub_errno;
>>> +          partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
>>> +                     diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
>>> +                     p->number + 1); /* one based partition number */
>>> +        }
>>> +      else if (!grub_strcmp (p->partmap->name, "gpt"))
>>> +        {
>>> +          const int guid_offset = 16; /* location in entry */
>>> +          dev->disk->partition = p->parent;
>>> +          /* little-endian 16-byte EFI partition GUID */
>>> +          err = grub_disk_read (dev->disk, p->offset, p->index +
>>> guid_offset, 16, diskbuf);
>>> +          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",
>>> +                     diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
>>> +                     diskbuf[5], diskbuf[4],
>>> +                     diskbuf[7], diskbuf[6],
>>> +                     diskbuf[8], diskbuf[9],
>>> +                     diskbuf[10], diskbuf[11], diskbuf[12],
>>> diskbuf[13], diskbuf[14], diskbuf[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");
>>>   }
>>>
> 


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

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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-14 19:12 ` Andrei Borzenkov
@ 2017-02-14 19:39   ` Steve Kenton
  2017-02-15  3:36     ` Nick Vinson
  0 siblings, 1 reply; 14+ messages in thread
From: Steve Kenton @ 2017-02-14 19:39 UTC (permalink / raw)
  To: Andrei Borzenkov, The development of GNU GRUB

Nick,

What is the state of your patch set? I think mine is much smaller if you 
want to roll it into yours and resubmit. We were told all along to wait 
until after 2.02, which should to be very soon, so it looks like it's 
show time!

Steve Kenton


On 02/14/2017 07:12 PM, Andrei Borzenkov wrote:
> 14.02.2017 21:00, Steve Kenton пишет:
>> Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val
>>
> Yes, I guess we need to add it finally. Unfortunately it is too late for
> 2.02, but it should go after in release. There were also patches for
> grub-probe and we also need to support it in search to be on par with
> filesystem UUID. May be if you could prepare consolidated patch set it
> would be great.
>
> I apologize that it tool so long. Thank you for not giving up!
>
>> Signed-off-by: Steve Kenton <skenton@ou.edu>
>> ---
>> It's been six months so I thought I'd resend this so it does not get lost
>> in case I get hit by a meteor or something before the next release
>>
>>   grub-core/commands/probe.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 53 insertions(+)
>>
>> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
>> index cf2793e..3afc8b8 100644
>> --- a/grub-core/commands/probe.c
>> +++ b/grub-core/commands/probe.c
> Please also add patch for manual.
>
>> @@ -45,6 +45,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 +155,58 @@ 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 */
>> +      grub_uint8_t diskbuf[16];
>> +      if (dev->disk && dev->disk->partition)
>> +	{
>> +	  grub_partition_t p = dev->disk->partition;
>> +	  if (!grub_strcmp (p->partmap->name, "msdos"))
>> +	    {
>> +	      const int diskid_offset = 440; /* location in MBR */
>> +	      dev->disk->partition = p->parent;
>> +	      /* little-endian 4-byte NT disk signature */
>> +	      err = grub_disk_read (dev->disk, 0, diskid_offset, 4, diskbuf);
>> +	      dev->disk->partition = p;
>> +	      if (err)
>> +	        return grub_errno;
>> +	      partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
>> +					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
>> +					 p->number + 1); /* one based partition number */
>> +	    }
>> +	  else if (!grub_strcmp (p->partmap->name, "gpt"))
>> +	    {
>> +	      const int guid_offset = 16; /* location in entry */
>> +	      dev->disk->partition = p->parent;
>> +	      /* little-endian 16-byte EFI partition GUID */
>> +	      err = grub_disk_read (dev->disk, p->offset, p->index + guid_offset, 16, diskbuf);
>> +	      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",
>> +					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
>> +					 diskbuf[5], diskbuf[4],
>> +					 diskbuf[7], diskbuf[6],
>> +					 diskbuf[8], diskbuf[9],
>> +					 diskbuf[10], diskbuf[11], diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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");
>>   }
>>



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

* Re: [PATCH 1/1] add --partuuid to probe
  2017-02-14 18:00 Steve Kenton
@ 2017-02-14 19:12 ` Andrei Borzenkov
  2017-02-14 19:39   ` Steve Kenton
  2017-02-15 10:56 ` Vladimir 'phcoder' Serbinenko
  1 sibling, 1 reply; 14+ messages in thread
From: Andrei Borzenkov @ 2017-02-14 19:12 UTC (permalink / raw)
  To: The development of GNU GRUB; +Cc: Steve Kenton

14.02.2017 21:00, Steve Kenton пишет:
> Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val
> 

Yes, I guess we need to add it finally. Unfortunately it is too late for
2.02, but it should go after in release. There were also patches for
grub-probe and we also need to support it in search to be on par with
filesystem UUID. May be if you could prepare consolidated patch set it
would be great.

I apologize that it tool so long. Thank you for not giving up!

> Signed-off-by: Steve Kenton <skenton@ou.edu>
> ---
> It's been six months so I thought I'd resend this so it does not get lost
> in case I get hit by a meteor or something before the next release
> 
>  grub-core/commands/probe.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 53 insertions(+)
> 
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index cf2793e..3afc8b8 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c

Please also add patch for manual.

> @@ -45,6 +45,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 +155,58 @@ 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 */
> +      grub_uint8_t diskbuf[16];
> +      if (dev->disk && dev->disk->partition)
> +	{
> +	  grub_partition_t p = dev->disk->partition;
> +	  if (!grub_strcmp (p->partmap->name, "msdos"))
> +	    {
> +	      const int diskid_offset = 440; /* location in MBR */
> +	      dev->disk->partition = p->parent;
> +	      /* little-endian 4-byte NT disk signature */
> +	      err = grub_disk_read (dev->disk, 0, diskid_offset, 4, diskbuf);
> +	      dev->disk->partition = p;
> +	      if (err)
> +	        return grub_errno;
> +	      partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
> +					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
> +					 p->number + 1); /* one based partition number */
> +	    }
> +	  else if (!grub_strcmp (p->partmap->name, "gpt"))
> +	    {
> +	      const int guid_offset = 16; /* location in entry */
> +	      dev->disk->partition = p->parent;
> +	      /* little-endian 16-byte EFI partition GUID */
> +	      err = grub_disk_read (dev->disk, p->offset, p->index + guid_offset, 16, diskbuf);
> +	      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",
> +					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
> +					 diskbuf[5], diskbuf[4],
> +					 diskbuf[7], diskbuf[6],
> +					 diskbuf[8], diskbuf[9],
> +					 diskbuf[10], diskbuf[11], diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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");
>  }
> 



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

* [PATCH 1/1] add --partuuid to probe
@ 2017-02-14 18:00 Steve Kenton
  2017-02-14 19:12 ` Andrei Borzenkov
  2017-02-15 10:56 ` Vladimir 'phcoder' Serbinenko
  0 siblings, 2 replies; 14+ messages in thread
From: Steve Kenton @ 2017-02-14 18:00 UTC (permalink / raw)
  To: grub-devel; +Cc: Steve Kenton

Support both EFI and NT Disk Signature for passing to kernel as root=PARTUUID=$val

Signed-off-by: Steve Kenton <skenton@ou.edu>
---
It's been six months so I thought I'd resend this so it does not get lost
in case I get hit by a meteor or something before the next release

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

diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
index cf2793e..3afc8b8 100644
--- a/grub-core/commands/probe.c
+++ b/grub-core/commands/probe.c
@@ -45,6 +45,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 +155,58 @@ 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 */
+      grub_uint8_t diskbuf[16];
+      if (dev->disk && dev->disk->partition)
+	{
+	  grub_partition_t p = dev->disk->partition;
+	  if (!grub_strcmp (p->partmap->name, "msdos"))
+	    {
+	      const int diskid_offset = 440; /* location in MBR */
+	      dev->disk->partition = p->parent;
+	      /* little-endian 4-byte NT disk signature */
+	      err = grub_disk_read (dev->disk, 0, diskid_offset, 4, diskbuf);
+	      dev->disk->partition = p;
+	      if (err)
+	        return grub_errno;
+	      partuuid = grub_xasprintf ("%02x%02x%02x%02x-%02x",
+					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
+					 p->number + 1); /* one based partition number */
+	    }
+	  else if (!grub_strcmp (p->partmap->name, "gpt"))
+	    {
+	      const int guid_offset = 16; /* location in entry */
+	      dev->disk->partition = p->parent;
+	      /* little-endian 16-byte EFI partition GUID */
+	      err = grub_disk_read (dev->disk, p->offset, p->index + guid_offset, 16, diskbuf);
+	      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",
+					 diskbuf[3], diskbuf[2], diskbuf[1], diskbuf[0],
+					 diskbuf[5], diskbuf[4],
+					 diskbuf[7], diskbuf[6],
+					 diskbuf[8], diskbuf[9],
+					 diskbuf[10], diskbuf[11], diskbuf[12], diskbuf[13], diskbuf[14], diskbuf[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.9.0.137.gcf4c2cf



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

end of thread, other threads:[~2017-02-28 14:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-16 14:56 [PATCH 1/1] add --partuuid to probe Steve Kenton
2017-02-14 18:00 Steve Kenton
2017-02-14 19:12 ` Andrei Borzenkov
2017-02-14 19:39   ` Steve Kenton
2017-02-15  3:36     ` Nick Vinson
2017-02-15 10:56 ` Vladimir 'phcoder' Serbinenko
2017-02-15 16:26   ` Andrei Borzenkov
2017-02-15 17:25     ` Vladimir 'phcoder' Serbinenko
2017-02-19  6:12       ` Andrei Borzenkov
2017-02-27  0:37         ` Vladimir 'phcoder' Serbinenko
2017-02-27 17:53           ` Andrei Borzenkov
2017-02-27 18:20             ` Vladimir 'phcoder' Serbinenko
2017-02-28  4:11               ` Andrei Borzenkov
2017-02-28 14:08                 ` Vladimir 'phcoder' Serbinenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.