Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iEumn-0004QK-GK for mharc-grub-devel@gnu.org; Mon, 30 Sep 2019 08:28:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34464) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEumk-0004QC-FA for grub-devel@gnu.org; Mon, 30 Sep 2019 08:28:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEumj-0006XD-8X for grub-devel@gnu.org; Mon, 30 Sep 2019 08:28:14 -0400 Received: from mail-qt1-x844.google.com ([2607:f8b0:4864:20::844]:37667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iEumj-0006Wy-3J for grub-devel@gnu.org; Mon, 30 Sep 2019 08:28:13 -0400 Received: by mail-qt1-x844.google.com with SMTP id l3so16740974qtr.4 for ; Mon, 30 Sep 2019 05:28:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eZxMEOC5IaVd0MoWMsAQ9vD0yzzbe2744aGdnJBv89w=; b=P/pj2a9RVvRmPH3TNHm+xBIZX6ewT5mRHwr+QXDksgjiWYBWTkyqdJlmwOX4VAqum0 KgFb0TC28QaKgVj/IEamwQ1Nqg6D+kY6gquck2OX/+Hxqrew/eWXYW2yFg5gW0LoaNzG gZWzZi+qJUn8iukQ28RxUDuXy/O0T3P7GM+eK4k92ZdzsCfLC2wzw6VbPiFVdYUat3aO X7PUqmfgJktxyra04YdW/zWuVmelSaplSGjDPhqYzgAXI5A3Jb1Zj66QOgS4wEm9d9tO oSAvMjBR6TINnJVfso6oCtY+n0j3ckm+1wzJPTWraTP5VVjDL0QFoSfara1+1o9Ii968 PawQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=eZxMEOC5IaVd0MoWMsAQ9vD0yzzbe2744aGdnJBv89w=; b=ZTCiucpeirNecz+CYu1OdMjpfHbRchYVocDu6PSW1uxsjg4X4sAdxBLxHc16Q3nspP OIocx5wnVbgFLxYaSdZWpdjjLS2kK1u7FjGpj25NeIZT3HDV9PJPUzcfqG+1iCG7h6VX 6VR5j52xiMD473CAqYuzpFXm6x0DAfihHxolsCbQ1fgtmFGIUjMpvTB6mCybZhsS3Kms diX6Xi+KGAhOdB2jLhzSgn3uKHiyhTPs2G+ZdH3QZgTO04ybAQL1kGnh1XD0wmekrhfW lx9IAHf2Ttt+50mY/03gsd9076oH3pD4qxlOQdYOT71aNGh1j9I9PXad8dh3/GnNduGs uuyg== X-Gm-Message-State: APjAAAXdpsWvM0GypK9ipgIN6aDWWVOueDScDzg+7jxdXzfUuzDaPwvI 2jQDl+j6zaxne5QzfUGxXx450eOi X-Google-Smtp-Source: APXvYqxLZnsKMmyx74JgZkmLtWF13khLNdoxsXbjTNFhZjLE/5yr1z5rld6kiHv3dgcjX9Urw2Kqwg== X-Received: by 2002:a05:6214:144f:: with SMTP id b15mr20182244qvy.171.1569846491761; Mon, 30 Sep 2019 05:28:11 -0700 (PDT) Received: from localhost.localdomain (cpe-2606-A000-111D-3FE-966E-1BA2-C222-3455.dyn6.twc.com. [2606:a000:111d:3fe:966e:1ba2:c222:3455]) by smtp.googlemail.com with ESMTPSA id b16sm9443597qtk.65.2019.09.30.05.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 05:28:11 -0700 (PDT) From: Nicholas Vinson To: grub-devel@gnu.org Cc: Nicholas Vinson Subject: [PATCH] probe: Support probing for msdos PARTUUID Date: Mon, 30 Sep 2019 08:27:59 -0400 Message-Id: <20190930122759.11249-1-nvinson234@gmail.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::844 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Sep 2019 12:28:15 -0000 Extend partition UUID probing support in GRUB core to display pseudo partition UUIDs for MBR (MSDOS) partitions. Signed-off-by: Nicholas Vinson --- grub-core/commands/probe.c | 43 +++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/grub-core/commands/probe.c b/grub-core/commands/probe.c index d2e7f662e..6d79810b4 100644 --- a/grub-core/commands/probe.c +++ b/grub-core/commands/probe.c @@ -32,6 +32,7 @@ #include #include #include +#include GRUB_MOD_LICENSE ("GPLv3+"); @@ -104,26 +105,40 @@ grub_cmd_probe (grub_extcmd_context_t ctxt, int argc, char **args) { /* AAAABBBB-CCCC-DDDD-EEEE-FFFFFFFFFFFF + null terminator */ char val[37] = "none"; - if (dev->disk && dev->disk->partition && - grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0) + if (dev->disk && dev->disk->partition) { - struct grub_gpt_partentry entry; struct grub_partition *p = dev->disk->partition; grub_disk_t disk = grub_disk_open(dev->disk->name); + if (!disk) return grub_errno; - if (grub_disk_read(disk, p->offset, p->index, sizeof(entry), &entry)) - return grub_errno; + if (grub_strcmp(dev->disk->partition->partmap->name, "gpt") == 0) + { + struct grub_gpt_partentry entry; + + if (grub_disk_read(disk, + p->offset, p->index, sizeof(entry), &entry)) + return grub_errno; + grub_gpt_part_guid_t *guid = &entry.guid; + grub_snprintf (val, sizeof(val), + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + grub_le_to_cpu32 (guid->data1), + grub_le_to_cpu16 (guid->data2), + grub_le_to_cpu16 (guid->data3), + guid->data4[0], guid->data4[1], guid->data4[2], + guid->data4[3], guid->data4[4], guid->data4[5], + guid->data4[6], guid->data4[7]); + } + else if (grub_strcmp(dev->disk->partition->partmap->name, "msdos") == 0) + { + grub_uint32_t nt_disk_sig; + + if (grub_disk_read(disk, 0, GRUB_BOOT_MACHINE_WINDOWS_NT_MAGIC, + sizeof(nt_disk_sig), &nt_disk_sig) == 0) + grub_snprintf (val, sizeof(val), "%08x-%02x", + grub_le_to_cpu32(nt_disk_sig), 1 + p->number); + } grub_disk_close(disk); - grub_gpt_part_guid_t *guid = &entry.guid; - grub_snprintf (val, sizeof(val), - "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - grub_le_to_cpu32 (guid->data1), - grub_le_to_cpu16 (guid->data2), - grub_le_to_cpu16 (guid->data3), - guid->data4[0], guid->data4[1], guid->data4[2], - guid->data4[3], guid->data4[4], guid->data4[5], - guid->data4[6], guid->data4[7]); } if (state[0].set) grub_env_set (state[0].arg, val); -- 2.23.0