summaryrefslogtreecommitdiff
path: root/gptpart.cc
diff options
context:
space:
mode:
authorRoderick W. Smith <rodsmith@rodsbooks.com>2014-02-22 12:12:32 -0500
committerRoderick W. Smith <rodsmith@rodsbooks.com>2014-02-22 12:12:32 -0500
commita345a922606a88447d2d89e28189d5372a75ea07 (patch)
treea3a7293c901ee8b1d0f17cec8ececc5f2be045da /gptpart.cc
parent820d1d04a3a76fb7699063597aac55742cc28d4a (diff)
downloadsgdisk-a345a922606a88447d2d89e28189d5372a75ea07.tar.gz
Refinements to new treatment of hybrid MBR and MBR conversions that
span the 2TiB boundary.
Diffstat (limited to 'gptpart.cc')
-rw-r--r--gptpart.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/gptpart.cc b/gptpart.cc
index d06145c..d780ec1 100644
--- a/gptpart.cc
+++ b/gptpart.cc
@@ -138,9 +138,17 @@ int GPTPart::IsUsed(void) {
return (partitionType != GUIDData("0x00"));
} // GPTPart::IsUsed()
-// Returns 1 if the partition's end point is under (2^32 - 1) sectors, 0 if it's over that value.
+// Returns MBR_SIZED_GOOD, MBR_SIZED_IFFY, or MBR_SIZED_BAD; see comments
+// in header file for details.
int GPTPart::IsSizedForMBR(void) {
- return (lastLBA < UINT32_MAX);
+ int retval = MBR_SIZED_GOOD;
+
+ if ((firstLBA > UINT32_MAX) || ((lastLBA - firstLBA) > UINT32_MAX) || (firstLBA > lastLBA))
+ retval = MBR_SIZED_BAD;
+ else if (lastLBA > UINT32_MAX)
+ retval = MBR_SIZED_IFFY;
+
+ return (retval);
} // GPTPart::IsSizedForMBR()
// Set the type code to the specified one. Also changes the partition