grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH 1/1] add --partuuid to probe


From: Nick Vinson
Subject: Re: [PATCH 1/1] add --partuuid to probe
Date: Tue, 14 Feb 2017 19:36:28 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0

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 <address@hidden>
>>> ---
>>> 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: signature.asc
Description: OpenPGP digital signature


reply via email to

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