summaryrefslogtreecommitdiff
path: root/gpt.cc
diff options
context:
space:
mode:
authorRoderick W. Smith <rodsmith@rodsbooks.com>2014-01-25 23:46:42 -0500
committerRoderick W. Smith <rodsmith@rodsbooks.com>2014-01-25 23:46:42 -0500
commit4a702a2e26420e14592cba64701d85ec9f1f70dc (patch)
tree6b4ba9de774382a6f7e9f0f44ca486dabf671bba /gpt.cc
parentb784e0c95a11cdaad05b0f62806114ead678a2b0 (diff)
downloadsgdisk-4a702a2e26420e14592cba64701d85ec9f1f70dc.tar.gz
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.
Diffstat (limited to 'gpt.cc')
-rw-r--r--gpt.cc21
1 files changed, 21 insertions, 0 deletions
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();