forked from bottlerocket-os/bottlerocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0013-tests-add-some-partitions-to-the-gpt-unit-test-data.patch
127 lines (117 loc) · 4.98 KB
/
0013-tests-add-some-partitions-to-the-gpt-unit-test-data.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
From 564616c70c7a914f385cfa36e0bb214cf75723a3 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Thu, 27 Nov 2014 15:49:57 -0800
Subject: [PATCH] tests: add some partitions to the gpt unit test data
---
tests/gpt_unit_test.c | 65 ++++++++++++++++++++++++++++++++++++-------
1 file changed, 55 insertions(+), 10 deletions(-)
diff --git a/tests/gpt_unit_test.c b/tests/gpt_unit_test.c
index 86e4364..5692a5a 100644
--- a/tests/gpt_unit_test.c
+++ b/tests/gpt_unit_test.c
@@ -89,12 +89,12 @@ struct test_data
};
-/* Sample primary GPT header for an empty 1MB disk. */
+/* Sample primary GPT header for a 1MB disk. */
static const struct grub_gpt_header example_primary = {
.magic = GRUB_GPT_HEADER_MAGIC,
.version = GRUB_GPT_HEADER_VERSION,
.headersize = sizeof (struct grub_gpt_header),
- .crc32 = grub_cpu_to_le32_compile_time (0x7cd8642c),
+ .crc32 = grub_cpu_to_le32_compile_time (0xb985abe0),
.header_lba = grub_cpu_to_le64_compile_time (PRIMARY_HEADER_SECTOR),
.alternate_lba = grub_cpu_to_le64_compile_time (BACKUP_HEADER_SECTOR),
.start = grub_cpu_to_le64_compile_time (DATA_START_SECTOR),
@@ -104,7 +104,52 @@ static const struct grub_gpt_header example_primary = {
.partitions = grub_cpu_to_le64_compile_time (PRIMARY_TABLE_SECTOR),
.maxpart = grub_cpu_to_le32_compile_time (TABLE_ENTRIES),
.partentry_size = grub_cpu_to_le32_compile_time (ENTRY_SIZE),
- .partentry_crc32 = grub_cpu_to_le32_compile_time (0xab54d286),
+ .partentry_crc32 = grub_cpu_to_le32_compile_time (0x074e052c),
+};
+
+static const struct grub_gpt_partentry example_entries[TABLE_ENTRIES] = {
+ {
+ .type = GRUB_GPT_PARTITION_TYPE_EFI_SYSTEM,
+ .guid = GRUB_GPT_GUID_INIT (0xa0f1792e, 0xb4ce, 0x4136, 0xbc, 0xf2,
+ 0x1a, 0xfc, 0x13, 0x3c, 0x28, 0x28),
+ .start = grub_cpu_to_le64_compile_time (DATA_START_SECTOR),
+ .end = grub_cpu_to_le64_compile_time (0x3f),
+ .attrib = 0x0,
+ .name = {
+ grub_cpu_to_le16_compile_time ('E'),
+ grub_cpu_to_le16_compile_time ('F'),
+ grub_cpu_to_le16_compile_time ('I'),
+ grub_cpu_to_le16_compile_time (' '),
+ grub_cpu_to_le16_compile_time ('S'),
+ grub_cpu_to_le16_compile_time ('Y'),
+ grub_cpu_to_le16_compile_time ('S'),
+ grub_cpu_to_le16_compile_time ('T'),
+ grub_cpu_to_le16_compile_time ('E'),
+ grub_cpu_to_le16_compile_time ('M'),
+ 0x0,
+ }
+ },
+ {
+ .type = GRUB_GPT_PARTITION_TYPE_BIOS_BOOT,
+ .guid = GRUB_GPT_GUID_INIT (0x876c898d, 0x1b40, 0x4727, 0xa1, 0x61,
+ 0xed, 0xf9, 0xb5, 0x48, 0x66, 0x74),
+ .start = grub_cpu_to_le64_compile_time (0x40),
+ .end = grub_cpu_to_le64_compile_time (0x7f),
+ .attrib = grub_cpu_to_le64_compile_time (
+ 1ULL << GRUB_GPT_PART_ATTR_OFFSET_LEGACY_BIOS_BOOTABLE),
+ .name = {
+ grub_cpu_to_le16_compile_time ('B'),
+ grub_cpu_to_le16_compile_time ('I'),
+ grub_cpu_to_le16_compile_time ('O'),
+ grub_cpu_to_le16_compile_time ('S'),
+ grub_cpu_to_le16_compile_time (' '),
+ grub_cpu_to_le16_compile_time ('B'),
+ grub_cpu_to_le16_compile_time ('O'),
+ grub_cpu_to_le16_compile_time ('O'),
+ grub_cpu_to_le16_compile_time ('T'),
+ 0x0,
+ }
+ },
};
/* And the backup header. */
@@ -112,7 +157,7 @@ static const struct grub_gpt_header example_backup = {
.magic = GRUB_GPT_HEADER_MAGIC,
.version = GRUB_GPT_HEADER_VERSION,
.headersize = sizeof (struct grub_gpt_header),
- .crc32 = grub_cpu_to_le32_compile_time (0xcfaa4a27),
+ .crc32 = grub_cpu_to_le32_compile_time (0x0af785eb),
.header_lba = grub_cpu_to_le64_compile_time (BACKUP_HEADER_SECTOR),
.alternate_lba = grub_cpu_to_le64_compile_time (PRIMARY_HEADER_SECTOR),
.start = grub_cpu_to_le64_compile_time (DATA_START_SECTOR),
@@ -122,7 +167,7 @@ static const struct grub_gpt_header example_backup = {
.partitions = grub_cpu_to_le64_compile_time (BACKUP_TABLE_SECTOR),
.maxpart = grub_cpu_to_le32_compile_time (TABLE_ENTRIES),
.partentry_size = grub_cpu_to_le32_compile_time (ENTRY_SIZE),
- .partentry_crc32 = grub_cpu_to_le32_compile_time (0xab54d286),
+ .partentry_crc32 = grub_cpu_to_le32_compile_time (0x074e052c),
};
/* Sample protective MBR for the same 1MB disk. Note, this matches
@@ -192,6 +237,10 @@ reset_disk (struct test_data *data)
memcpy (&data->raw->mbr, &example_pmbr, sizeof (data->raw->mbr));
memcpy (&data->raw->primary_header, &example_primary,
sizeof (data->raw->primary_header));
+ memcpy (&data->raw->primary_entries, &example_entries,
+ sizeof (data->raw->primary_entries));
+ memcpy (&data->raw->backup_entries, &example_entries,
+ sizeof (data->raw->backup_entries));
memcpy (&data->raw->backup_header, &example_backup,
sizeof (data->raw->backup_header));
@@ -270,11 +319,7 @@ read_disk (struct test_data *data)
gpt = grub_gpt_read (data->dev->disk);
if (gpt == NULL)
- {
- grub_print_error ();
- grub_fatal ("grub_gpt_read failed");
- }
-
+ grub_fatal ("grub_gpt_read failed: %s", grub_errmsg);
return gpt;
}
--
2.21.3