diff mbox

[v2] disk: part_efi: add support for the Secondary GPT

Message ID 1399315169-25273-1-git-send-email-srae@broadcom.com
State New
Headers show

Commit Message

Steve Rae May 5, 2014, 6:39 p.m. UTC
Check the Secondary GPT table if the Primary GPT table is invalid.

Signed-off-by: Steve Rae <srae@broadcom.com>
---

Changes in v2:
- changed wording: "Alternate" to "Secondary"

 disk/part_efi.c | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 216a292..f909229 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -93,7 +93,15 @@  void print_part_efi(block_dev_desc_t * dev_desc)
 	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
 			 gpt_head, &gpt_pte) != 1) {
 		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		return;
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {
+			printf("%s: *** ERROR: Invalid Secondary GPT ***\n",
+			       __func__);
+			return;
+		} else {
+			printf("%s: ***        Using Secondary GPT ***\n",
+			       __func__);
+		}
 	}
 
 	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
@@ -142,7 +150,15 @@  int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 	if (is_gpt_valid(dev_desc, GPT_PRIMARY_PARTITION_TABLE_LBA,
 			gpt_head, &gpt_pte) != 1) {
 		printf("%s: *** ERROR: Invalid GPT ***\n", __func__);
-		return -1;
+		if (is_gpt_valid(dev_desc, (dev_desc->lba - 1),
+				 gpt_head, &gpt_pte) != 1) {
+			printf("%s: *** ERROR: Invalid Secondary GPT ***\n",
+			       __func__);
+			return -1;
+		} else {
+			printf("%s: ***        Using Secondary GPT ***\n",
+			       __func__);
+		}
 	}
 
 	if (part > le32_to_cpu(gpt_head->num_partition_entries) ||