From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1eiQGj-0007gC-SA for mharc-grub-devel@gnu.org; Sun, 04 Feb 2018 14:48:05 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eiQGi-0007fj-9K for grub-devel@gnu.org; Sun, 04 Feb 2018 14:48:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eiQGh-0001AA-6d for grub-devel@gnu.org; Sun, 04 Feb 2018 14:48:04 -0500 Received: from mail-pl0-x229.google.com ([2607:f8b0:400e:c01::229]:37586) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eiQGg-00019h-UP for grub-devel@gnu.org; Sun, 04 Feb 2018 14:48:03 -0500 Received: by mail-pl0-x229.google.com with SMTP id ay8so10337529plb.4 for ; Sun, 04 Feb 2018 11:48:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=KPNFky0lP3YoibZSojWqlzPelMzsjwHRfD+NXDyLijg=; b=Le9+snUWGtZPmriYqjKcnV3pGzYVySd5opwLCA27GUPHwrwdDiAGQMdYJ3C5s0v0vH mmNyQyib81UDq9N/q2KvYPGRGKKZ2wxiBRtWwNVH6JK9qS7oFmQGRS6yPQehJspqu1ur iPNisZahrNIpmTVamijphUWB70U1UXI3e9xk4ZNH1Av0w6zCAr/mhZl+rlvS8NBGRaqy ODvoTpjVNq5njE5R/7uF3dhnJLcwr9FiRrbROsgse6t/CqCGgHqV6E2Zt57uc82NEkyT 39PMMrIp5vK3HQAAtJViMfCsHwe3agq8M8eFjBpoJyHBzijs1ANThc45Mg/wMSIt/GT1 u08Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=KPNFky0lP3YoibZSojWqlzPelMzsjwHRfD+NXDyLijg=; b=PU1hhUB9EiVh1XbX4pW/SoOhCd5ylCorUnlr+LOQ8MQ+fxB8dkF5aO0FwT2I5Vf4Lf 4VMAW9dguLMZkhLCTUAeV9qLQ+gks5MBac9T8xf97Ey7laTBcgbNqnidDyURkn6wtgFc E8WIUVWlW8UZWBAJCERZ5Lw2zIak29J044TxhFGKOopsoPgME8TUC5UsdbEzJhy1hyTw 0bXyNA/1A7sTHCYNGbaRzA6USs4uM6f/+bPU74+PwCtvMqDGlxA5Hy2HQ2q5bKbIb5Bc 8jnEbxiP2NDE8sPjEOJVeisiBdXh0SmLD9GupQ1WodXRPAlhYzj3Fp0BIt9OXMOBIPPY ihng== X-Gm-Message-State: AKwxytctjSS4Onv7HT8V9kENJekY9HsWRMrSzh143kli1EZ5iBddmPqG D6gnTPzQm5iB61uv28+bL/aCGQ== X-Google-Smtp-Source: AH8x227BqRhMMggN64ztS9x4eC1q2BX+CbV1lfbgBEPEURkHffShK6F0lpfl0BmDCHwIn0Mrp4ifPw== X-Received: by 2002:a17:902:a585:: with SMTP id az5-v6mr22199803plb.167.1517773681497; Sun, 04 Feb 2018 11:48:01 -0800 (PST) Received: from localhost.localdomain ([2601:602:9c01:e86a:2ec2:3a19:cd81:76ab]) by smtp.googlemail.com with ESMTPSA id v20sm13565736pfe.176.2018.02.04.11.48.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Feb 2018 11:48:00 -0800 (PST) From: Nicholas Vinson To: grub-devel@gnu.org Subject: [GRUB PARTUUID PATCH V5 1/3] Update grub_gpt_partentry; centralize guid prints Date: Sun, 4 Feb 2018 11:47:35 -0800 Message-Id: <20180204194737.22662-2-nvinson234@gmail.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180204194737.22662-1-nvinson234@gmail.com> References: <20180204194737.22662-1-nvinson234@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::229 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: Sun, 04 Feb 2018 19:48:05 -0000 To help clean the code and simplify the code in util/grub-probe.c, this patch renames grub_gpt_part_type to grub_gpt_part_guid and updates grub_gpt_partentry to use this type for both the partition type GUID string and the partition GUID string entries. This patch also moves the GUID printing logic in util/grub-probe.c to a separate function. This change allows the partuuid logic in the next commit to use the same printing logic without having to completely duplicate it. --- grub-core/disk/ldm.c | 2 +- grub-core/partmap/gpt.c | 4 ++-- include/grub/gpt_partition.h | 8 ++++---- util/grub-install.c | 2 +- util/grub-probe.c | 30 +++++++++++++++--------------- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/grub-core/disk/ldm.c b/grub-core/disk/ldm.c index 0f978ad05..2a22d2d6c 100644 --- a/grub-core/disk/ldm.c +++ b/grub-core/disk/ldm.c @@ -135,7 +135,7 @@ msdos_has_ldm_partition (grub_disk_t dsk) return has_ldm; } -static const grub_gpt_part_type_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM; +static const grub_gpt_part_guid_t ldm_type = GRUB_GPT_PARTITION_TYPE_LDM; /* Helper for gpt_ldm_sector. */ static int diff --git a/grub-core/partmap/gpt.c b/grub-core/partmap/gpt.c index 83bcba779..103f6796f 100644 --- a/grub-core/partmap/gpt.c +++ b/grub-core/partmap/gpt.c @@ -33,10 +33,10 @@ static grub_uint8_t grub_gpt_magic[8] = 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 }; -static const grub_gpt_part_type_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; +static const grub_gpt_part_guid_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; #ifdef GRUB_UTIL -static const grub_gpt_part_type_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT; +static const grub_gpt_part_guid_t grub_gpt_partition_type_bios_boot = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT; #endif /* 512 << 7 = 65536 byte sectors. */ diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h index 1b32f6725..354fe2246 100644 --- a/include/grub/gpt_partition.h +++ b/include/grub/gpt_partition.h @@ -22,14 +22,14 @@ #include #include -struct grub_gpt_part_type +struct grub_gpt_part_guid { grub_uint32_t data1; grub_uint16_t data2; grub_uint16_t data3; grub_uint8_t data4[8]; } __attribute__ ((aligned(8))); -typedef struct grub_gpt_part_type grub_gpt_part_type_t; +typedef struct grub_gpt_part_guid grub_gpt_part_guid_t; #define GRUB_GPT_PARTITION_TYPE_EMPTY \ { 0x0, 0x0, 0x0, \ @@ -70,8 +70,8 @@ struct grub_gpt_header struct grub_gpt_partentry { - grub_gpt_part_type_t type; - grub_uint8_t guid[16]; + grub_gpt_part_guid_t type; + grub_gpt_part_guid_t guid; grub_uint64_t start; grub_uint64_t end; grub_uint64_t attrib; diff --git a/util/grub-install.c b/util/grub-install.c index 5e4cdfd2b..783f62acf 100644 --- a/util/grub-install.c +++ b/util/grub-install.c @@ -714,7 +714,7 @@ is_prep_partition (grub_device_t dev) if (grub_disk_read (dev->disk, p->offset, p->index, sizeof (gptdata), &gptdata) == 0) { - const grub_gpt_part_type_t template = { + const grub_gpt_part_guid_t template = { grub_cpu_to_le32_compile_time (0x9e1a2d38), grub_cpu_to_le16_compile_time (0xc612), grub_cpu_to_le16_compile_time (0x4316), diff --git a/util/grub-probe.c b/util/grub-probe.c index 8ac527d2f..21cb80fbe 100644 --- a/util/grub-probe.c +++ b/util/grub-probe.c @@ -129,6 +129,20 @@ get_targets_string (void) return str; } +static int +print_gpt_guid (grub_gpt_part_guid_t guid) +{ + guid.data1 = grub_le_to_cpu32 (guid.data1); + guid.data2 = grub_le_to_cpu16 (guid.data2); + guid.data3 = grub_le_to_cpu16 (guid.data3); + + return grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + guid.data1, guid.data2, 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]); +} + static void do_print (const char *x, void *data) { @@ -641,21 +655,7 @@ probe (const char *path, char **device_names, char delim) if (grub_disk_read (dev->disk, p->offset, p->index, sizeof (gptdata), &gptdata) == 0) - { - grub_gpt_part_type_t gpttype; - gpttype.data1 = grub_le_to_cpu32 (gptdata.type.data1); - gpttype.data2 = grub_le_to_cpu16 (gptdata.type.data2); - gpttype.data3 = grub_le_to_cpu16 (gptdata.type.data3); - grub_memcpy (gpttype.data4, gptdata.type.data4, 8); - - grub_printf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", - gpttype.data1, gpttype.data2, - gpttype.data3, gpttype.data4[0], - gpttype.data4[1], gpttype.data4[2], - gpttype.data4[3], gpttype.data4[4], - gpttype.data4[5], gpttype.data4[6], - gpttype.data4[7]); - } + print_gpt_guid(gptdata.type); dev->disk->partition = p; } putchar (delim); -- 2.15.1