From: Andrei Borzenkov <arvidjaar@gmail.com>
To: Steve Kenton <skenton@ou.edu>,
The development of GNU GRUB <grub-devel@gnu.org>
Cc: Nicholas Vinson <nvinson234@gmail.com>
Subject: Re: Adding partition guid/uuid to the probe command for use with Linux kernel command line root=PARTUUID=$guid
Date: Mon, 15 Aug 2016 07:04:20 +0300 [thread overview]
Message-ID: <c36db5a1-d9f3-8d16-7664-1dec95461854@gmail.com> (raw)
In-Reply-To: <d9fcbf37-011a-058b-18ee-1acac4c176b8@ou.edu>
14.08.2016 21:31, Steve Kenton пишет:
> I have not look at NTFS yet, but is this more what you were wanting? I'm
Yes. Did you test it?
> not sure about the printing, should grub_gpt_partentry.guid[16] change
> to a UUID struct?
>
It may make sense if we started to actually use it. Actually we may
probably just as well get rid of special case grub_gpt_part_type_t.
> Steve Kenton
>
> diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c
> index cf2793e..8ff4ff9 100644
> --- a/grub-core/commands/probe.c
> +++ b/grub-core/commands/probe.c
> @@ -24,6 +24,7 @@
> #include <grub/device.h>
> #include <grub/disk.h>
> #include <grub/partition.h>
> +#include <grub/gpt_partition.h>
> #include <grub/net.h>
> #include <grub/fs.h>
> #include <grub/file.h>
> @@ -45,6 +46,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},
> + {"partguid", 'g', 0, N_("Determine partition guid."), 0, 0},
Linux is using PARTUUID and patches from Nicholas use --target=partuuid,
so let's stick to it.
> {0, 0, 0, 0, 0, 0}
> };
>
> @@ -154,6 +156,43 @@ 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 *val;
> + struct grub_gpt_partentry entry;
> + if (dev->disk && dev->disk->partition)
> + {
> + if (grub_strcmp (dev->disk->partition->partmap->name, "gpt"))
> + return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
> + N_("partition map %s does not support partition GUIDs"),
> dev->disk->partition->partmap->name);
> + if (grub_disk_read (dev->disk, dev->disk->partition->offset,
> dev->disk->partition->index, sizeof(entry), &entry))
You need to read from partition parent, not from partition itself. Usual
hack is to reset disk->partition = disk->partition->parent. See e.g. in
gpt.c itself or in mentioned grub-probe patches.
May be we need to provide something like grub_read_partition_container()
to encapsulate it.
> + return grub_errno;
> +#if 0
> + val = grub_xasprintf
> ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", /* should
> grub_gpt_partentry.guid[16] change to a UUID struct? */
> + grub_be_to_cpu32 (*(grub_uint32_t *) &entry.guid[0]),
> + grub_be_to_cpu16 (*(grub_uint16_t *) &entry.guid[4]),
> + grub_be_to_cpu16 (*(grub_uint16_t *) &entry.guid[6]),
> + entry.guid[8], entry.guid[9],
> + entry.guid[10], entry.guid[11], entry.guid[12], entry.guid[13],
> entry.guid[14], entry.guid[15]);
> +#else
> + val = grub_xasprintf
> ("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
> /* guid is big-endian */
No, EFI GUIDs are little-endian as was discussed in another subthread.
See also grub-probe patches.
> + entry.guid[0], entry.guid[1], entry.guid[2], entry.guid[3],
> + entry.guid[4], entry.guid[5],
> + entry.guid[6], entry.guid[7],
> + entry.guid[8], entry.guid[9],
> + entry.guid[10], entry.guid[11], entry.guid[12], entry.guid[13],
> entry.guid[14], entry.guid[15]);
> +#endif
> + }
> + else
> + val = grub_strdup(""); /* set guid to the empty string */
> + if (state[0].set)
> + grub_env_set (state[0].arg, val);
> + else
> + grub_printf ("%s", val);
> + grub_free (val);
> + grub_device_close (dev);
> + return GRUB_ERR_NONE;
> + }
> grub_device_close (dev);
> return grub_error (GRUB_ERR_BAD_ARGUMENT, "unrecognised target");
> }
next prev parent reply other threads:[~2016-08-15 4:04 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-12 14:11 Grub module to return partuuid of a device such as (hd0, gpt1) at boot time Steve Kenton
2016-08-13 17:30 ` adrian15
2016-08-13 18:40 ` Andrei Borzenkov
2016-08-13 20:25 ` Steve Kenton
2016-08-14 7:13 ` Andrei Borzenkov
2016-08-14 9:09 ` Thomas Schmitt
2016-08-14 11:55 ` Andrei Borzenkov
2016-08-14 13:55 ` Thomas Schmitt
2016-08-14 15:44 ` Thomas Schmitt
2016-08-14 16:06 ` Andrei Borzenkov
2016-08-14 18:24 ` Thomas Schmitt
2016-08-14 16:05 ` Andrei Borzenkov
2016-08-14 12:32 ` Steve Kenton
2016-08-14 18:31 ` Adding partition guid/uuid to the probe command for use with Linux kernel command line root=PARTUUID=$guid Steve Kenton
2016-08-15 4:04 ` Andrei Borzenkov [this message]
2016-08-15 5:09 ` Steve Kenton
2016-08-14 4:12 ` Grub module to return partuuid of a device such as (hd0, gpt1) at boot time Michael Zimmermann
2016-08-14 6:42 ` Andrei Borzenkov
2016-08-13 20:30 ` Steve Kenton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c36db5a1-d9f3-8d16-7664-1dec95461854@gmail.com \
--to=arvidjaar@gmail.com \
--cc=grub-devel@gnu.org \
--cc=nvinson234@gmail.com \
--cc=skenton@ou.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).