summaryrefslogtreecommitdiff
path: root/mbr.cc
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2010-09-22 01:07:31 -0400
committersrs5694 <srs5694@users.sourceforge.net>2010-09-22 01:07:31 -0400
commit327129e9331f888a8fc08d688dcb0a739a3c17be (patch)
treed47eeb130686d47a0800d45e6f2a530374f4c293 /mbr.cc
parent659eaf1552778f5d62878e59bb66ba6fe404a6bf (diff)
downloadsgdisk-327129e9331f888a8fc08d688dcb0a739a3c17be.tar.gz
sgdisk can now accept GUID values with its -t option. Also some
additional checks for hybrid MBR issues.
Diffstat (limited to 'mbr.cc')
-rw-r--r--mbr.cc38
1 files changed, 38 insertions, 0 deletions
diff --git a/mbr.cc b/mbr.cc
index 3a5aec4..e0e92a3 100644
--- a/mbr.cc
+++ b/mbr.cc
@@ -535,6 +535,44 @@ int MBRData::LBAtoCHS(uint64_t lba, uint8_t * chs) {
return (retval);
} // MBRData::LBAtoCHS()
+// Look for problems -- overlapping partitions, etc.
+int MBRData::Verify(void) {
+ int i, j, theyOverlap, numProbs = 0, numEE = 0;
+ uint32_t firstLBA1, firstLBA2, lastLBA1, lastLBA2;
+
+ for (i = 0; i < MAX_MBR_PARTS; i++) {
+ for (j = i + 1; j < MAX_MBR_PARTS; j++) {
+ theyOverlap = 0;
+ firstLBA1 = partitions[i].firstLBA;
+ firstLBA2 = partitions[j].firstLBA;
+ if ((firstLBA1 != 0) && (firstLBA2 != 0)) {
+ lastLBA1 = partitions[i].firstLBA + partitions[i].lengthLBA - 1;
+ lastLBA2 = partitions[j].firstLBA + partitions[j].lengthLBA - 1;
+ if ((firstLBA1 < lastLBA2) && (lastLBA1 >= firstLBA2))
+ theyOverlap = 1;
+ if ((firstLBA2 < lastLBA1) && (lastLBA2 >= firstLBA1))
+ theyOverlap = 1;
+ } // if
+ if (theyOverlap) {
+ numProbs++;
+ cout << "\nProblem: MBR partitions " << i + 1 << " and " << j + 1
+ << " overlap!\n";
+ } // if
+ } // for (j...)
+ if (partitions[i].partitionType == 0xEE) {
+ numEE++;
+ if (partitions[i].firstLBA != 1)
+ cout << "\nWarning: 0xEE partition doesn't start on sector 1. This can cause problems\n"
+ << "in some OSes.\n";
+ } // if
+ } // for (i...)
+ if (numEE > 1)
+ cout << "\nCaution: More than one 0xEE MBR partition found. This can cause problems\n"
+ << "in some OSes.\n";
+
+ return numProbs;
+} // MBRData::Verify()
+
/*****************************************************
* *
* Functions to create, delete, or change partitions *