From e26ef5524c955533cf47a148e8157c74090cc794 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 24 Jan 2013 01:13:46 +0100 Subject: [PATCH] gpt: the disk system now correctly maintains free space. * Ie. the BPartitioningInfo should now be correctly filled. --- .../disk_systems/gpt/GPTPartitionHandle.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp index abff127287..8efba5100f 100644 --- a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp +++ b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp @@ -102,12 +102,19 @@ GPTPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info) { // init to the full size (minus the first sector) off_t size = Partition()->ContentSize(); - status_t error = info->SetTo(Partition()->BlockSize(), + status_t status = info->SetTo(Partition()->BlockSize(), size - Partition()->BlockSize()); - if (error != B_OK) - return error; + if (status != B_OK) + return status; - // TODO: exclude the space of the existing partitions + // Exclude the space of the existing partitions + size_t count = Partition()->CountChildren(); + for (size_t index = 0; index < count; index++) { + BMutablePartition* child = Partition()->ChildAt(index); + status = info->ExcludeOccupiedSpace(child->Offset(), child->Size()); + if (status != B_OK) + return status; + } return B_OK; }