Received: from list by lists.gnu.org with archive (Exim 4.71) id 1cdiWW-000350-BZ for mharc-grub-devel@gnu.org; Tue, 14 Feb 2017 14:12:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35608) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cdiWU-00034p-8r for grub-devel@gnu.org; Tue, 14 Feb 2017 14:12:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cdiWQ-0001Js-UP for grub-devel@gnu.org; Tue, 14 Feb 2017 14:12:22 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:34348) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cdiWQ-0001Hv-MI for grub-devel@gnu.org; Tue, 14 Feb 2017 14:12:18 -0500 Received: by mail-lf0-x243.google.com with SMTP id q89so11774012lfi.1 for ; Tue, 14 Feb 2017 11:12:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=HM44+GC/dW+FTnROykuEu5m7wixKYAW5sBhIzCVWjnA=; b=ehgWk7WLSbVqcN5xxB6Q372nj/mA6vqNPU4QVexzn4Lg+o3YSHbRmyxMuEyIubAs1y oORMvnVEPlZJPp4HfjVKFiXy5l/Ru7pfKvK0sgN2Sx1Nnw7D55uzSpBJF0CI+4pIbmtG uStCKxzI/hLpQ4eGQEkX5G0UzijwHjVi5dWbgvWFn1t7OU5ZtaWxm2/4YeQN+hGfwF5V A0qWBNv6JnPjykDhrd7YWc29/Wwsh09n9n4+JKFgXyZ/wHnQyyLyhKpUZaAsqDgh/hgD W0Ib7fMsd4d/jPOPhynzGI91T8dBo5ZvZNtSEy0wYUhIIksVM9jRWdXhedfAO68qTmuI 3gpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=HM44+GC/dW+FTnROykuEu5m7wixKYAW5sBhIzCVWjnA=; b=ZrHYjWWhJTz7cRzuYJ02PN4Th34zd+3fJoGdzafPAg8S42vtc5AGO/ww2s/prCkQam qQoGz28+PSkKDoi5/dhLU4Mjo41ELfFlkUhSZBXoTbrmr134NW5MNkdZPZc7dLqN2wbt 6n4MW4g+fF5DaKn78hD+BI0PPMstpu1nIgsTQ13PD4I7V/bPebhpykjlNuwPVjdU6MCk dT1cdt0LJocv3+HxuCr+m3xrDeZmZ68cUlwsHEwCfdQc2Tuwy6GOyCxli+1R31sptoFQ lN47xrTlb5FNkXWOo7yL6mrdVLu/lwf4/n1eVvlHiIXi/SnUP2Zx18QVbNhtxNmHwAao AeNg== X-Gm-Message-State: AMke39n8Byrq9MoPulIeyib7tF++wAGVKmcLP3jakT6sbdH23jG232iSDnwh78Q7SqLkbQ== X-Received: by 10.25.211.132 with SMTP id k126mr10154848lfg.61.1487099535880; Tue, 14 Feb 2017 11:12:15 -0800 (PST) Received: from [192.168.1.6] (ppp109-252-90-129.pppoe.spdop.ru. [109.252.90.129]) by smtp.gmail.com with ESMTPSA id 12sm357287lju.16.2017.02.14.11.12.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 11:12:15 -0800 (PST) Subject: Re: [PATCH 1/1] add --partuuid to probe To: The development of GNU GRUB References: <20170214180035.3461-1-skenton@ou.edu> Cc: Steve Kenton From: Andrei Borzenkov Message-ID: Date: Tue, 14 Feb 2017 22:12:12 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170214180035.3461-1-skenton@ou.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::243 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: Tue, 14 Feb 2017 19:12:23 -0000 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 > --- > 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"); > } >