From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ce2Pq-0008Qe-G0 for mharc-grub-devel@gnu.org; Wed, 15 Feb 2017 11:26:50 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ce2Po-0008OR-5I for grub-devel@gnu.org; Wed, 15 Feb 2017 11:26:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ce2Pl-0006Db-0A for grub-devel@gnu.org; Wed, 15 Feb 2017 11:26:48 -0500 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:34047) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ce2Pk-0006Cx-Gr for grub-devel@gnu.org; Wed, 15 Feb 2017 11:26:44 -0500 Received: by mail-lf0-x243.google.com with SMTP id q89so13859799lfi.1 for ; Wed, 15 Feb 2017 08:26:44 -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=r69SQ0/ln3nWRjMZ7Qd4Irygf5EKYB5rshC4XmNeIi4=; b=hWYB5r/5YcCkChFywlQOgyzyrPnp1IPrjPB6RB4gSgoCwvd2TeB5Bv6GwG0WY3Xa+n Ok182JbtYF/TuIRrgRuAp5TkfA5lgWGleh6OnnsS6GE68QnCliPinlEh+SvaN/27Gki7 SY76Kkh/LEB4rnw3oe2zmymgtAWuz59E4KLPRcV6HSyBvOwVDFbAc5E3iB29MpLqmRC2 4qip31kbD3JnxiyNRm1EM2GG+ve70f0gtaIuGcFGzZNg5o4vR6hfEmHB/yTN/BxD/H9u RKOYeofcSxOGDWyCb98sUSwsAmPqgaTf1CLU3GoOC8mHdOg1ICJvhm2vOp7/uZ+1PvJu H1DA== 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=r69SQ0/ln3nWRjMZ7Qd4Irygf5EKYB5rshC4XmNeIi4=; b=EoNB7RKBQHTKnMWS9y4VBjdGyF2DeB4BPELJon6VKpgToSB0ydFGrHFPbihOW4Oowq ZZ8vPp83zSaKvHAk5Jjvt8WN8Lxxo3T/gr/U3C2OoPPYkUqlAjqXfimOkH8vfR9BSuYa JZv2yV3m5Wrxetfslh4Yv1gGCYknC2/13Vp/kITQwmWlS8CTvWGWMsVd087Q2UfGMrGn bRGJsS60Zq3lvEUY+SpR+RAdQz+ZxdLDY3JCHHu/mGyPxMrlhrVtBP2rbV2Qx2hCbtSd o3yX+DGu/WRflaz/bQ0GmAY8mVKJHhhYUux8em9UVa6/XGu41t1T3nzJ3pFA0/sViDl9 dQJw== X-Gm-Message-State: AMke39nMq6C8yEHqENwbNOVsZKw7iJhvRl3foNj/HpdL0UdWfjk1bSjDUv6vGMG3+TtpBw== X-Received: by 10.25.92.217 with SMTP id u86mr12388432lfi.5.1487176003110; Wed, 15 Feb 2017 08:26:43 -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 s7sm1057254lja.27.2017.02.15.08.26.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Feb 2017 08:26:41 -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: Wed, 15 Feb 2017 19:26:41 +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: 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: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: Wed, 15 Feb 2017 16:26:49 -0000 15.02.2017 13:56, Vladimir 'phcoder' Serbinenko пишет: > On Tue, Feb 14, 2017, 19:01 Steve Kenton wrote: > >> Support both EFI and NT Disk Signature for passing to kernel as >> root=PARTUUID=$val >> >> 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 >> @@ -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" */ >> > I like how it generalizes. > >> {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")) >> > Please use == 0 rather than ! > >> + { >> + const int diskid_offset = 440; /* location in MBR */ >> > Please get this from a common header rather than hard coding. I think we > have it in msdos.h > >> + 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 */ >> > This is not NT-style. NT uses partition offset. Who uses this format? Are This is used by util-linux and Linux kernel. * 6) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the * unique id of a partition if the partition table provides it. * The UUID may be either an EFI/GPT UUID, or refer to an MSDOS * partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero- * filled hex representation of the 32-bit "NT disk signature", and PP * is a zero-filled hex representation of the 1-based partition number. > you sure that partition numbers are synced with user? Even in presence of > Solaris and bsd partitions. > It is not clear what we should return for nested partition. I'm not sure whether linux kernel scans nested partitions at all in which case we probably should follow the suite and assign PARTUUID to top-level partitions only. >> + } >> + else if (!grub_strcmp (p->partmap->name, "gpt")) >> > Ditto. > >> + { >> + const int guid_offset = 16; /* location in entry */ >> > Ditto. > >> + 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"); >> } >> -- >> 2.9.0.137.gcf4c2cf >> >> >> _______________________________________________ >> Grub-devel mailing list >> Grub-devel@gnu.org >> https://lists.gnu.org/mailman/listinfo/grub-devel >> > > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >