[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Adding partition guid/uuid to the probe command for use with Linux k
From: |
Andrei Borzenkov |
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 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 |
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");
> }
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, (continued)
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Andrei Borzenkov, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Thomas Schmitt, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Andrei Borzenkov, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Thomas Schmitt, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Thomas Schmitt, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Andrei Borzenkov, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Thomas Schmitt, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Andrei Borzenkov, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Steve Kenton, 2016/08/14
- Adding partition guid/uuid to the probe command for use with Linux kernel command line root=PARTUUID=$guid, Steve Kenton, 2016/08/14
- Re: Adding partition guid/uuid to the probe command for use with Linux kernel command line root=PARTUUID=$guid,
Andrei Borzenkov <=
- Re: Adding partition guid/uuid to the probe command for use with Linux kernel command line root=PARTUUID=$guid, Steve Kenton, 2016/08/15
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Michael Zimmermann, 2016/08/14
- Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Andrei Borzenkov, 2016/08/14
Re: Grub module to return partuuid of a device such as (hd0, gpt1) at boot time, Steve Kenton, 2016/08/13