summaryrefslogtreecommitdiff
path: root/basicmbr.cc
diff options
context:
space:
mode:
authorRoderick W. Smith <rodsmith@rodsbooks.com>2013-09-12 12:37:44 -0400
committerRoderick W. Smith <rodsmith@rodsbooks.com>2013-09-12 12:37:44 -0400
commit427c799b611e357223da28c778a08451fb789590 (patch)
tree7651635958c1f1555bc7f097daf21cc34f6107dc /basicmbr.cc
parent042f38a2f716fd4a3b9b03c35951e69f1d1bc942 (diff)
downloadsgdisk-427c799b611e357223da28c778a08451fb789590.tar.gz
Fixed hybrid creation bug on over-2TiB disks & improved verification
('v') detection of disks with 0xEE partitions that don't begin on sector 1.
Diffstat (limited to 'basicmbr.cc')
-rw-r--r--basicmbr.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/basicmbr.cc b/basicmbr.cc
index 080de76..6cea80f 100644
--- a/basicmbr.cc
+++ b/basicmbr.cc
@@ -701,10 +701,11 @@ int BasicMBRData::LBAtoCHS(uint64_t lba, uint8_t * chs) {
return (retval);
} // BasicMBRData::LBAtoCHS()
-// Look for overlapping partitions.
+// Look for overlapping partitions. Also looks for a couple of non-error
+// conditions that the user should be told about.
// Returns the number of problems found
int BasicMBRData::FindOverlaps(void) {
- int i, j, numProbs = 0, numEE = 0;
+ int i, j, numProbs = 0, numEE = 0, ProtectiveOnOne = 0;
for (i = 0; i < MAX_MBR_PARTS; i++) {
for (j = i + 1; j < MAX_MBR_PARTS; j++) {
@@ -717,14 +718,17 @@ int BasicMBRData::FindOverlaps(void) {
} // for (j...)
if (partitions[i].GetType() == 0xEE) {
numEE++;
- if (partitions[i].GetStartLBA() != 1)
- cout << "\nWarning: 0xEE partition doesn't start on sector 1. This can cause "
- << "problems\nin some OSes.\n";
+ if (partitions[i].GetStartLBA() == 1)
+ ProtectiveOnOne = 1;
} // if
} // for (i...)
+
if (numEE > 1)
cout << "\nCaution: More than one 0xEE MBR partition found. This can cause problems\n"
<< "in some OSes.\n";
+ if (!ProtectiveOnOne)
+ cout << "\nWarning: 0xEE partition doesn't start on sector 1. This can cause "
+ << "problems\nin some OSes.\n";
return numProbs;
} // BasicMBRData::FindOverlaps()
@@ -927,7 +931,7 @@ int BasicMBRData::IsEEActive(void) {
int i, IsActive = FALSE;
for (i = 0; i < MAX_MBR_PARTS; i++) {
- if (partitions[i].GetStatus() & 0x80)
+ if ((partitions[i].GetStatus() & 0x80) && (partitions[i].GetType() == 0xEE))
IsActive = TRUE;
}
return IsActive;
@@ -1056,6 +1060,7 @@ int BasicMBRData::MakeBiggestPart(int i, int type) {
uint64_t selectedSegment = UINT64_C(0); // location of largest segment
uint64_t selectedSize = UINT64_C(0); // size of largest segment in blocks
int found = 0;
+ string anything;
do {
firstBlock = FindFirstAvailable(start);
@@ -1375,6 +1380,9 @@ uint64_t BasicMBRData::FindFirstAvailable(uint64_t start) {
uint64_t i;
int firstMoved;
+ if ((start >= (UINT32_MAX - 1)) || (start >= (diskSize - 1)))
+ return 0;
+
first = start;
// ...now search through all partitions; if first is within an