forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0011-gpt-move-gpt-guid-printing-function-to-common-librar.patch
80 lines (72 loc) · 2.62 KB
/
0011-gpt-move-gpt-guid-printing-function-to-common-librar.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
From 44c916ad1a8ae8fbd3743f269fd13cc677a932da Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Thu, 27 Nov 2014 12:55:53 -0800
Subject: [PATCH] gpt: move gpt guid printing function to common library
---
grub-core/commands/gptprio.c | 16 ++--------------
grub-core/lib/gpt.c | 13 +++++++++++++
include/grub/gpt_partition.h | 4 ++++
3 files changed, 19 insertions(+), 14 deletions(-)
diff --git a/grub-core/commands/gptprio.c b/grub-core/commands/gptprio.c
index 1e2e06c..2415747 100644
--- a/grub-core/commands/gptprio.c
+++ b/grub-core/commands/gptprio.c
@@ -141,20 +141,8 @@ grub_find_next (const char *disk_name,
if (!*part_name)
goto done;
- *part_guid =
- grub_xasprintf ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
- grub_le_to_cpu32 (part_found->guid.data1),
- grub_le_to_cpu16 (part_found->guid.data2),
- grub_le_to_cpu16 (part_found->guid.data3),
- part_found->guid.data4[0],
- part_found->guid.data4[1],
- part_found->guid.data4[2],
- part_found->guid.data4[3],
- part_found->guid.data4[4],
- part_found->guid.data4[5],
- part_found->guid.data4[6],
- part_found->guid.data4[7]);
- if (!*part_name)
+ *part_guid = grub_gpt_guid_to_str (&part_found->guid);
+ if (!*part_guid)
goto done;
grub_errno = GRUB_ERR_NONE;
diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index 1982340..9a1835b 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -31,6 +31,19 @@ GRUB_MOD_LICENSE ("GPLv3+");
static grub_uint8_t grub_gpt_magic[] = GRUB_GPT_HEADER_MAGIC;
+char *
+grub_gpt_guid_to_str (grub_gpt_guid_t *guid)
+{
+ return grub_xasprintf ("%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]);
+}
+
static grub_uint64_t
grub_gpt_size_to_sectors (grub_gpt_t gpt, grub_size_t size)
{
diff --git a/include/grub/gpt_partition.h b/include/grub/gpt_partition.h
index 7fbdf4c..dc1bcca 100644
--- a/include/grub/gpt_partition.h
+++ b/include/grub/gpt_partition.h
@@ -33,6 +33,10 @@ struct grub_gpt_guid
typedef struct grub_gpt_guid grub_gpt_guid_t;
typedef struct grub_gpt_guid grub_gpt_part_guid_t;
+/* Format the raw little-endian GUID as a newly allocated string. */
+char * grub_gpt_guid_to_str (grub_gpt_guid_t *guid);
+
+
#define GRUB_GPT_GUID_INIT(a, b, c, d1, d2, d3, d4, d5, d6, d7, d8) \
{ \
grub_cpu_to_le32_compile_time (a), \
--
2.21.3