Received: from list by lists.gnu.org with archive (Exim 4.71) id 1bZ98W-0000H6-PU for mharc-grub-devel@gnu.org; Mon, 15 Aug 2016 00:04:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48739) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZ98V-0000Gz-19 for grub-devel@gnu.org; Mon, 15 Aug 2016 00:04:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bZ98R-0007a2-Qz for grub-devel@gnu.org; Mon, 15 Aug 2016 00:04:26 -0400 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]:32886) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bZ98R-0007Zu-B8 for grub-devel@gnu.org; Mon, 15 Aug 2016 00:04:23 -0400 Received: by mail-wm0-x242.google.com with SMTP id o80so9122784wme.0 for ; Sun, 14 Aug 2016 21:04:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:cc:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=7gfwguDWEU4tp8W5tOI/UdwJLjUNwxMzxK5J8BZaVKI=; b=RDnyV75rXMKvHmMtewsFHJe4xBuoDIHwKUufMSmuGyRXORGMlAj+MUS/A0FjPqJc6b uwaA6BkVmonhSNXY/rL9HZhnU6Paib37Xi4ALvzMmPK+gkLfN40uv1Nk9cvGb2/9l1nd HMScPnHaB4g0PItREvfrPRLIsnGCazk94KZUcLd/PF6wnQcoVeAr/qvk6srx8Ecrryf4 dKsZJJCEQOWs1pwyx79aavbHaSYAbEfQ7XXq6kRfCe7dTbcf8/eH+jylKqcbjDoJTdsY RKIyhiX/WQaHQGQxTTvubOi7qvLXvtYRoUjG//582lXjW01zjf5r1mAc7NwmN7FVWOSE +WLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:cc:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=7gfwguDWEU4tp8W5tOI/UdwJLjUNwxMzxK5J8BZaVKI=; b=PdPXc2/5+H5wk+Rj+EQTdaZPMcJUbuxbOxp0vNlquvDi/LLRSIwsuGZprWXzjrSZ1Q sKsLlCDiqjqSSt2OBsRnH7RZc3/HpGudLXBSPpEt3NXrQSRVrp6iAPYDN5sHfAGpyB1U QF6PhOLzxkRZkVqBzd4iYkobzMqrqvfuoaHiWVezBhL7cSdp6fwrr6ZpgrYzgdZqyIU3 VpuCApC9sO5Hr6XXGwz8mP4bz3j038nsevfijM3+pywZ2XcLSZ48xae/GweFCamtxEYS vmpy+w2A0IVRM8p0Cml6upCz3WPk7999xHC3aMkw0ny1Fudf2cYzE0NuHDvxkUKIofFm y5Fg== X-Gm-Message-State: AEkoouvqVAgE/GDTMgwmnLMPvgoF9wKqrBIHkjoxJMjrdXeqUCyT26u7bx3akQJI/w0D0g== X-Received: by 10.46.71.144 with SMTP id u138mr4433234lja.20.1471233862392; Sun, 14 Aug 2016 21:04:22 -0700 (PDT) Received: from [192.168.1.43] (ppp109-252-91-231.pppoe.spdop.ru. [109.252.91.231]) by smtp.gmail.com with ESMTPSA id s187sm3054075lfd.3.2016.08.14.21.04.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 14 Aug 2016 21:04:21 -0700 (PDT) Subject: Re: Adding partition guid/uuid to the probe command for use with Linux kernel command line root=PARTUUID=$guid To: Steve Kenton , The development of GNU GRUB References: <57AF593D.4090608@gmail.com> <2dcb99b3-2755-66f3-9140-962454d33bb7@ou.edu> <8a631144-4854-98ff-8536-b73fdf3482db@ou.edu> From: Andrei Borzenkov X-Enigmail-Draft-Status: N1110 Cc: Nicholas Vinson Message-ID: 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 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:400c:c09::242 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Aug 2016 04:04:28 -0000 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 > #include > #include > +#include > #include > #include > #include > @@ -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"); > }