From 7813cb23eb6306a36534197985a1f859ff4fb048 Mon Sep 17 00:00:00 2001 From: Bryce Groff Date: Fri, 15 Oct 2010 07:24:16 +0000 Subject: [PATCH] - Truncate the previous partition if the current partition's offset lies within the previous partitions area. - Fixed spelling mistake. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38970 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../intel/PartitionMap.cpp | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp index e7f4a1f952..cb4d6206b7 100644 --- a/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp +++ b/src/add-ons/kernel/partitioning_systems/intel/PartitionMap.cpp @@ -833,11 +833,20 @@ PartitionMap::Check(off_t sessionSize) const off_t nextOffset = 0; for (int32 i = 0; i < byOffsetCount; i++) { const Partition* partition = byOffset[i]; - if (partition->Offset() < nextOffset) { - TRACE(("intel: PartitionMap::Check(): overlapping partitions!" - "\n")); - result = false; - break; + if (partition->Offset() < nextOffset && i > 0) { + Partition* previousPartition = (Partition*)byOffset[i - 1]; + off_t previousSize = previousPartition->Size() + - (nextOffset - partition->Offset()); + TRACE(("intel: PartitionMap::Check(): ")); + if (previousSize == 0) { + previousPartition->Unset(); + TRACE(("partition offset hides previous partition." + " Removing previous partition from disk layout.\n")); + } else { + TRACE(("overlapping partitions! Setting partition %ld " + "size to %lld\n", i - 1, previousSize)); + previousPartition->SetSize(previousSize); + } } nextOffset = partition->Offset() + partition->Size(); } @@ -847,7 +856,7 @@ PartitionMap::Check(off_t sessionSize) const if (result) { for (int32 i = 0; i < tableOffsetCount; i++) { if (i > 0 && tableOffsets[i] == tableOffsets[i - 1]) { - TRACE(("intel: PartitionMap::Check(): same partition talbe " + TRACE(("intel: PartitionMap::Check(): same partition table " "for different extended partitions!\n")); result = false; break;