-
Notifications
You must be signed in to change notification settings - Fork 521
/
Copy path0032-gpt-check-header-and-entries-status-bits-together.patch
46 lines (42 loc) · 1.91 KB
/
0032-gpt-check-header-and-entries-status-bits-together.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
From 3ffa128b0a04cc7c111cdfa2332e07e0977e3073 Mon Sep 17 00:00:00 2001
From: Michael Marineau <michael.marineau@coreos.com>
Date: Wed, 21 Sep 2016 13:44:11 -0700
Subject: [PATCH] gpt: check header and entries status bits together
Use the new status function which checks *_HEADER_VALID and
*_ENTRIES_VALID bits together. It doesn't make sense for the header and
entries bits to mismatch so don't allow for it.
---
grub-core/lib/gpt.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/grub-core/lib/gpt.c b/grub-core/lib/gpt.c
index 9bb19678d..3c6ff3540 100644
--- a/grub-core/lib/gpt.c
+++ b/grub-core/lib/gpt.c
@@ -596,24 +596,20 @@ grub_gpt_repair (grub_disk_t disk, grub_gpt_t gpt)
return grub_error (GRUB_ERR_NOT_IMPLEMENTED_YET,
"GPT sector size must match disk sector size");
- if (!(gpt->status & GRUB_GPT_PRIMARY_ENTRIES_VALID ||
- gpt->status & GRUB_GPT_BACKUP_ENTRIES_VALID))
- return grub_error (GRUB_ERR_BUG, "No valid GPT entries");
-
- if (gpt->status & GRUB_GPT_PRIMARY_HEADER_VALID)
+ if (grub_gpt_primary_valid (gpt))
{
- grub_dprintf ("gpt", "primary GPT header is valid\n");
+ grub_dprintf ("gpt", "primary GPT is valid\n");
backup_header = grub_le_to_cpu64 (gpt->primary.alternate_lba);
grub_memcpy (&gpt->backup, &gpt->primary, sizeof (gpt->backup));
}
- else if (gpt->status & GRUB_GPT_BACKUP_HEADER_VALID)
+ else if (grub_gpt_backup_valid (gpt))
{
- grub_dprintf ("gpt", "backup GPT header is valid\n");
+ grub_dprintf ("gpt", "backup GPT is valid\n");
backup_header = grub_le_to_cpu64 (gpt->backup.header_lba);
grub_memcpy (&gpt->primary, &gpt->backup, sizeof (gpt->primary));
}
else
- return grub_error (GRUB_ERR_BUG, "No valid GPT header");
+ return grub_error (GRUB_ERR_BUG, "No valid GPT");
/* Relocate backup to end if disk whenever possible. */
if (grub_gpt_disk_size_valid(disk))