From 4a702a2e26420e14592cba64701d85ec9f1f70dc Mon Sep 17 00:00:00 2001 From: "Roderick W. Smith" Date: Sat, 25 Jan 2014 23:46:42 -0500 Subject: New checks for an oversized 0xEE protective (or any hybrid MBR) partition. Auto-corrects on loading if protective & otherwise valid; if not, verify and save operations warn of the problem. --- gpt.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gpt.cc') diff --git a/gpt.cc b/gpt.cc index 23e1bb2..fa7b661 100644 --- a/gpt.cc +++ b/gpt.cc @@ -291,6 +291,12 @@ int GPTData::Verify(void) { // Verify that partitions don't run into GPT data areas.... problems += CheckGPTSize(); + if (!protectiveMBR.DoTheyFit()) { + cout << "\nPartition(s) in the protective MBR are too big for the disk! Creating a\n" + << "fresh protective or hybrid MBR is recommended.\n"; + problems++; + } + // Check that partitions are aligned on proper boundaries (for WD Advanced // Format and similar disks).... for (i = 0; i < numParts; i++) { @@ -681,6 +687,15 @@ void GPTData::PartitionScan(void) { // Load the GPT data, whether or not it's valid ForceLoadGPTData(); + // Some tools create a 0xEE partition that's too big. If this is detected, + // normalize it.... + if ((state == gpt_valid) && !protectiveMBR.DoTheyFit() && (protectiveMBR.GetValidity() == gpt)) { + if (!beQuiet) { + cerr << "\aThe protective MBR's 0xEE partition is oversized! Auto-repairing.\n\n"; + } // if + protectiveMBR.MakeProtectiveMBR(); + } // if + if (!beQuiet) { cout << "Partition table scan:\n"; protectiveMBR.ShowState(); @@ -1056,6 +1071,12 @@ int GPTData::SaveGPTData(int quiet) { cerr << "Aborting write operation!\n"; } // if + // Check that protective MBR fits, and warn if it doesn't.... + if (!protectiveMBR.DoTheyFit()) { + cerr << "\nPartition(s) in the protective MBR are too big for the disk! Creating a\n" + << "fresh protective or hybrid MBR is recommended.\n"; + } + // Check for mismatched MBR and GPT data, but let it pass if found // (function displays warning message) FindHybridMismatches(); -- cgit v1.2.1