diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index 055d45a2f..2e6489a97 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -117,6 +117,7 @@ if ( KPMcore_FOUND ) include_directories( ${KPMCORE_INCLUDE_DIR} ) list( APPEND libSources partition/PartitionIterator.cpp + partition/PartitionQuery.cpp ) list( APPEND OPTIONAL_PRIVATE_LIBRARIES kpmcore ) endif() diff --git a/src/libcalamares/partition/PartitionQuery.cpp b/src/libcalamares/partition/PartitionQuery.cpp new file mode 100644 index 000000000..b7f2beda3 --- /dev/null +++ b/src/libcalamares/partition/PartitionQuery.cpp @@ -0,0 +1,95 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * Copyright 2015-2016, Teo Mrnjavac + * Copyright 2018-2019 Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ + +#include "PartitionQuery.h" + +#include "PartitionIterator.h" + +#include +#include + +namespace CalamaresUtils +{ +namespace Partition +{ + +// Types from KPMCore +using ::Device; +using ::Partition; + +bool +isPartitionFreeSpace( Partition* partition ) +{ + return partition->roles().has( PartitionRole::Unallocated ); +} + + +bool +isPartitionNew( Partition* partition ) +{ +#if defined( WITH_KPMCORE4API ) + constexpr auto NewState = Partition::State::New; +#else + constexpr auto NewState = Partition::StateNew; +#endif + return partition->state() == NewState; +} + + +Partition* +findPartitionByCurrentMountPoint( const QList< Device* >& devices, const QString& mountPoint ) +{ + for ( auto device : devices ) + for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) + if ( (*it)->mountPoint() == mountPoint ) + return *it; + return nullptr; +} + + +Partition* +findPartitionByPath( const QList< Device* >& devices, const QString& path ) +{ + if ( path.simplified().isEmpty() ) + return nullptr; + + for ( auto device : devices ) + for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) + if ( ( *it )->partitionPath() == path.simplified() ) + return *it; + return nullptr; +} + + +QList< Partition* > +findPartitions( const QList< Device* >& devices, + std::function< bool ( Partition* ) > criterionFunction ) +{ + QList< Partition* > results; + for ( auto device : devices ) + for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) + if ( criterionFunction( *it ) ) + results.append( *it ); + return results; +} + + +} +} // namespace diff --git a/src/libcalamares/partition/PartitionQuery.h b/src/libcalamares/partition/PartitionQuery.h new file mode 100644 index 000000000..14b98c799 --- /dev/null +++ b/src/libcalamares/partition/PartitionQuery.h @@ -0,0 +1,70 @@ +/* === This file is part of Calamares - === + * + * Copyright 2014, Aurélien Gâteau + * Copyright 2015-2016, Teo Mrnjavac + * Copyright 2019, Adriaan de Groot + * + * Calamares is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calamares is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calamares. If not, see . + */ +#ifndef PARTITION_PARTITIONQUERY_H +#define PARTITION_PARTITIONQUERY_H + +#include + +#include + +#include + +class Device; +class Partition; + +namespace CalamaresUtils +{ +namespace Partition +{ +/** @brief Is this a free-space area? */ +bool isPartitionFreeSpace( ::Partition* ); + +/** @brief Is this partition newly-to-be-created? + * + * Returns true if the partition is planned to be created by the installer as + * opposed to already existing on the disk. + */ +bool isPartitionNew( ::Partition* ); + +/** + * Iterates on all devices and return the first partition which is (already) + * mounted on @p mountPoint. + */ +::Partition* findPartitionByCurrentMountPoint( const QList< ::Device* >& devices, const QString& mountPoint ); + +// TODO: add this distinction +// ::Partition* findPartitionByIntendedMountPoint( const QList< ::Device* >& devices, const QString& mountPoint ); + +/** + * Iterates on all devices and partitions and returns a pointer to the Partition object + * for the given path, or nullptr if a Partition for the given path cannot be found. + */ +::Partition* findPartitionByPath( const QList< ::Device* >& devices, const QString& path ); + +/** + * Iterates on all devices and partitions and returns a list of pointers to the Partition + * objects that satisfy the conditions defined in the criterion function. + */ +QList< ::Partition* > findPartitions( const QList< ::Device* >& devices, + std::function< bool ( ::Partition* ) > criterionFunction ); +} +} + +#endif // PARTITION_PARTITIONQUERY_H diff --git a/src/modules/partition/core/ColorUtils.cpp b/src/modules/partition/core/ColorUtils.cpp index 843b02711..63f51cddf 100644 --- a/src/modules/partition/core/ColorUtils.cpp +++ b/src/modules/partition/core/ColorUtils.cpp @@ -22,6 +22,7 @@ #include "core/KPMHelpers.h" #include "partition/PartitionIterator.h" +#include "partition/PartitionQuery.h" #include "utils/Logger.h" // KPMcore @@ -33,6 +34,8 @@ #include using CalamaresUtils::Partition::PartitionIterator; +using CalamaresUtils::Partition::isPartitionFreeSpace; +using CalamaresUtils::Partition::isPartitionNew; static const int NUM_PARTITION_COLORS = 5; static const int NUM_NEW_PARTITION_COLORS = 4; @@ -91,7 +94,7 @@ colorForPartition( Partition* partition ) return FREE_SPACE_COLOR; } - if ( KPMHelpers::isPartitionFreeSpace( partition ) ) + if ( isPartitionFreeSpace( partition ) ) return FREE_SPACE_COLOR; if ( partition->roles().has( PartitionRole::Extended ) ) return EXTENDED_COLOR; @@ -126,16 +129,16 @@ colorForPartition( Partition* partition ) Partition* child = *it; if ( child == partition ) break; - if ( !KPMHelpers::isPartitionFreeSpace( child ) && + if ( !isPartitionFreeSpace( child ) && !child->hasChildren() ) { - if ( KPMHelpers::isPartitionNew( child ) ) + if ( isPartitionNew( child ) ) ++newColorIdx; ++colorIdx; } } - if ( KPMHelpers::isPartitionNew( partition ) ) + if ( isPartitionNew( partition ) ) return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ]; if ( partition->fileSystem().supportGetUUID() != FileSystem::cmdSupportNone && @@ -172,9 +175,9 @@ colorForPartitionInFreeSpace( Partition* partition ) Partition* child = *it; if ( child == partition ) break; - if ( !KPMHelpers::isPartitionFreeSpace( child ) && + if ( !isPartitionFreeSpace( child ) && !child->hasChildren() && - KPMHelpers::isPartitionNew( child ) ) + isPartitionNew( child ) ) ++newColorIdx; } return NEW_PARTITION_COLORS[ newColorIdx % NUM_NEW_PARTITION_COLORS ]; diff --git a/src/modules/partition/core/KPMHelpers.cpp b/src/modules/partition/core/KPMHelpers.cpp index 1e5770b26..782cd4f13 100644 --- a/src/modules/partition/core/KPMHelpers.cpp +++ b/src/modules/partition/core/KPMHelpers.cpp @@ -56,20 +56,6 @@ initKPMcore() } -bool -isPartitionFreeSpace( Partition* partition ) -{ - return partition->roles().has( PartitionRole::Unallocated ); -} - - -bool -isPartitionNew( Partition* partition ) -{ - return partition->state() == KPM_PARTITION_STATE(New); -} - - Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ) { @@ -81,33 +67,6 @@ findPartitionByMountPoint( const QList< Device* >& devices, const QString& mount } -Partition* -findPartitionByPath( const QList< Device* >& devices, const QString& path ) -{ - if ( path.simplified().isEmpty() ) - return nullptr; - - for ( auto device : devices ) - for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) - if ( ( *it )->partitionPath() == path.simplified() ) - return *it; - return nullptr; -} - - -QList< Partition* > -findPartitions( const QList< Device* >& devices, - std::function< bool ( Partition* ) > criterionFunction ) -{ - QList< Partition* > results; - for ( auto device : devices ) - for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) - if ( criterionFunction( *it ) ) - results.append( *it ); - return results; -} - - Partition* createNewPartition( PartitionNode* parent, const Device& device, diff --git a/src/modules/partition/core/KPMHelpers.h b/src/modules/partition/core/KPMHelpers.h index 6cc8aac7b..206746c44 100644 --- a/src/modules/partition/core/KPMHelpers.h +++ b/src/modules/partition/core/KPMHelpers.h @@ -63,33 +63,12 @@ namespace KPMHelpers */ bool initKPMcore(); -bool isPartitionFreeSpace( Partition* ); - -/** - * Returns true if the partition is planned to be created by the installer as - * opposed to already existing on the disk. - */ -bool isPartitionNew( Partition* ); - /** * Iterates on all devices and return the first partition which is associated * with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint() */ Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint ); -/** - * Iterates on all devices and partitions and returns a pointer to the Partition object - * for the given path, or nullptr if a Partition for the given path cannot be found. - */ -Partition* findPartitionByPath( const QList< Device* >& devices, const QString& path ); - -/** - * Iterates on all devices and partitions and returns a list of pointers to the Partition - * objects that satisfy the conditions defined in the criterion function. - */ -QList< Partition* > findPartitions( const QList< Device* >& devices, - std::function< bool ( Partition* ) > criterionFunction ); - /** * Helper function to create a new Partition object (does not create anything * on the disk) associated with a FileSystem. diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 4a70848a5..093f2720b 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -29,6 +29,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" #include "partition/PartitionIterator.h" +#include "partition/PartitionQuery.h" #include "utils/CalamaresUtilsSystem.h" #include "utils/Logger.h" @@ -37,10 +38,12 @@ #include #include - #include #include +using CalamaresUtils::Partition::isPartitionFreeSpace; +using CalamaresUtils::Partition::isPartitionNew; + namespace PartUtils { @@ -133,7 +136,7 @@ canBeResized( Partition* candidate ) return false; } - if ( KPMHelpers::isPartitionFreeSpace( candidate ) ) + if ( isPartitionFreeSpace( candidate ) ) { cDebug() << Logger::SubEntry << "NO, partition is free space"; return false; @@ -206,7 +209,7 @@ canBeResized( PartitionCoreModule* core, const QString& partitionPath ) for ( int i = 0; i < dm->rowCount(); ++i ) { Device* dev = dm->deviceForIndex( dm->index( i ) ); - Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, partitionWithOs ); + Partition* candidate = CalamaresUtils::Partition::findPartitionByPath( { dev }, partitionWithOs ); if ( candidate ) { return canBeResized( candidate ); diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 261ff4696..ef9b8ccfe 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -48,6 +48,7 @@ #include "JobExample.h" #endif #include "partition/PartitionIterator.h" +#include "partition/PartitionQuery.h" #include "utils/Logger.h" #include "utils/Variant.h" @@ -70,6 +71,8 @@ #include using CalamaresUtils::Partition::PartitionIterator; +using CalamaresUtils::Partition::isPartitionFreeSpace; +using CalamaresUtils::Partition::isPartitionNew; PartitionCoreModule::RefreshHelper::RefreshHelper(PartitionCoreModule* module) : m_module( module ) @@ -395,7 +398,7 @@ PartitionCoreModule::deletePartition( Device* device, Partition* partition ) // deleting them, so let's play it safe and keep our own list. QList< Partition* > lst; for ( auto childPartition : partition->children() ) - if ( !KPMHelpers::isPartitionFreeSpace( childPartition ) ) + if ( !isPartitionFreeSpace( childPartition ) ) lst << childPartition; for ( auto childPartition : lst ) @@ -653,7 +656,7 @@ PartitionCoreModule::scanForEfiSystemPartitions() } QList< Partition* > efiSystemPartitions = - KPMHelpers::findPartitions( devices, PartUtils::isEfiBootable ); + CalamaresUtils::Partition::findPartitions( devices, PartUtils::isEfiBootable ); if ( efiSystemPartitions.isEmpty() ) cWarning() << "system is EFI but no EFI system partitions found."; diff --git a/src/modules/partition/core/PartitionModel.cpp b/src/modules/partition/core/PartitionModel.cpp index 8b13ab0a0..370c2d2d2 100644 --- a/src/modules/partition/core/PartitionModel.cpp +++ b/src/modules/partition/core/PartitionModel.cpp @@ -22,6 +22,8 @@ #include "core/ColorUtils.h" #include "core/PartitionInfo.h" #include "core/KPMHelpers.h" + +#include "partition/PartitionQuery.h" #include "utils/Logger.h" // CalaPM @@ -36,6 +38,9 @@ // Qt #include +using CalamaresUtils::Partition::isPartitionFreeSpace; +using CalamaresUtils::Partition::isPartitionNew; + //- ResetHelper -------------------------------------------- PartitionModel::ResetHelper::ResetHelper( PartitionModel* model ) : m_model( model ) @@ -140,11 +145,11 @@ PartitionModel::data( const QModelIndex& index, int role ) const int col = index.column(); if ( col == NameColumn ) { - if ( KPMHelpers::isPartitionFreeSpace( partition ) ) + if ( isPartitionFreeSpace( partition ) ) return tr( "Free Space" ); else { - return KPMHelpers::isPartitionNew( partition ) + return isPartitionNew( partition ) ? tr( "New partition" ) : partition->partitionPath(); } @@ -172,11 +177,11 @@ PartitionModel::data( const QModelIndex& index, int role ) const QString name; if ( col == NameColumn ) { - if ( KPMHelpers::isPartitionFreeSpace( partition ) ) + if ( isPartitionFreeSpace( partition ) ) name = tr( "Free Space" ); else { - name = KPMHelpers::isPartitionNew( partition ) + name = isPartitionNew( partition ) ? tr( "New partition" ) : partition->partitionPath(); } @@ -189,10 +194,10 @@ PartitionModel::data( const QModelIndex& index, int role ) const case SizeRole: return ( partition->lastSector() - partition->firstSector() + 1 ) * m_device->logicalSize(); case IsFreeSpaceRole: - return KPMHelpers::isPartitionFreeSpace( partition ); + return isPartitionFreeSpace( partition ); case IsPartitionNewRole: - return KPMHelpers::isPartitionNew( partition ); + return isPartitionNew( partition ); case FileSystemLabelRole: if ( partition->fileSystem().supportGetLabel() != FileSystem::cmdSupportNone && diff --git a/src/modules/partition/gui/ChoicePage.cpp b/src/modules/partition/gui/ChoicePage.cpp index 719e91dec..aebf9a7f6 100644 --- a/src/modules/partition/gui/ChoicePage.cpp +++ b/src/modules/partition/gui/ChoicePage.cpp @@ -42,6 +42,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" #include "partition/PartitionIterator.h" +#include "partition/PartitionQuery.h" #include "utils/Logger.h" #include "utils/Retranslator.h" #include "utils/Units.h" @@ -66,6 +67,8 @@ using PartitionActions::Choices::SwapChoice; using CalamaresUtils::Partition::PartitionIterator; +using CalamaresUtils::Partition::isPartitionFreeSpace; +using CalamaresUtils::Partition::findPartitionByPath; /** @brief Given a set of swap choices, return a sensible value from it. * @@ -692,7 +695,7 @@ ChoicePage::doAlongsideApply() for ( int i = 0; i < dm->rowCount(); ++i ) { Device* dev = dm->deviceForIndex( dm->index( i ) ); - Partition* candidate = KPMHelpers::findPartitionByPath( { dev }, path ); + Partition* candidate = findPartitionByPath( { dev }, path ); if ( candidate ) { qint64 firstSector = candidate->firstSector(); @@ -755,7 +758,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) Partition* selectedPartition = static_cast< Partition* >( current.data( PartitionModel::PartitionPtrRole ) .value< void* >() ); - if ( KPMHelpers::isPartitionFreeSpace( selectedPartition ) ) + if ( isPartitionFreeSpace( selectedPartition ) ) { //NOTE: if the selected partition is free space, we don't deal with // a separate /home partition at all because there's no existing @@ -769,7 +772,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) if ( parent && parent->roles().has( PartitionRole::Extended ) ) { newRoles = PartitionRole( PartitionRole::Logical ); - newParent = KPMHelpers::findPartitionByPath( { selectedDevice() }, parent->partitionPath() ); + newParent = findPartitionByPath( { selectedDevice() }, parent->partitionPath() ); } } @@ -783,7 +786,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) // We can't use the PartitionPtrRole because we need to make changes to the // main DeviceModel, not the immutable copy. QString partPath = current.data( PartitionModel::PartitionPathRole ).toString(); - selectedPartition = KPMHelpers::findPartitionByPath( { selectedDevice() }, + selectedPartition = findPartitionByPath( { selectedDevice() }, partPath ); if ( selectedPartition ) { @@ -806,7 +809,7 @@ ChoicePage::doReplaceSelectedPartition( const QModelIndex& current ) gs->value( "defaultFileSystemType" ).toString(), m_encryptWidget->passphrase() } ); - Partition* homePartition = KPMHelpers::findPartitionByPath( { selectedDevice() }, + Partition* homePartition = findPartitionByPath( { selectedDevice() }, *homePartitionPath ); if ( homePartition && doReuseHomePartition ) diff --git a/src/modules/partition/gui/CreatePartitionDialog.cpp b/src/modules/partition/gui/CreatePartitionDialog.cpp index 7823d743d..aef5f2ad9 100644 --- a/src/modules/partition/gui/CreatePartitionDialog.cpp +++ b/src/modules/partition/gui/CreatePartitionDialog.cpp @@ -31,9 +31,10 @@ #include "ui_CreatePartitionDialog.h" -#include "utils/Logger.h" #include "GlobalStorage.h" #include "JobQueue.h" +#include "partition/PartitionQuery.h" +#include "utils/Logger.h" // KPMcore #include @@ -272,7 +273,7 @@ CreatePartitionDialog::checkMountPointSelection() void CreatePartitionDialog::initPartResizerWidget( Partition* partition ) { - QColor color = KPMHelpers::isPartitionFreeSpace( partition ) + QColor color = CalamaresUtils::Partition::isPartitionFreeSpace( partition ) ? ColorUtils::colorForPartitionInFreeSpace( partition ) : ColorUtils::colorForPartition( partition ); m_partitionSizeController->init( m_device, partition, color ); diff --git a/src/modules/partition/gui/PartitionPage.cpp b/src/modules/partition/gui/PartitionPage.cpp index 915f899b2..d2ad49c23 100644 --- a/src/modules/partition/gui/PartitionPage.cpp +++ b/src/modules/partition/gui/PartitionPage.cpp @@ -40,11 +40,13 @@ #include "ui_PartitionPage.h" #include "ui_CreatePartitionTableDialog.h" +#include "GlobalStorage.h" +#include "JobQueue.h" +#include "partition/PartitionQuery.h" #include "utils/Logger.h" #include "utils/Retranslator.h" + #include "Branding.h" -#include "JobQueue.h" -#include "GlobalStorage.h" // KPMcore #include @@ -132,7 +134,7 @@ PartitionPage::updateButtons() Q_ASSERT( model ); Partition* partition = model->partitionForIndex( index ); Q_ASSERT( partition ); - bool isFree = KPMHelpers::isPartitionFreeSpace( partition ); + bool isFree = CalamaresUtils::Partition::isPartitionFreeSpace( partition ); bool isExtended = partition->roles().has( PartitionRole::Extended ); bool isInVG = m_core->isInVG( partition ); @@ -392,7 +394,7 @@ PartitionPage::onEditClicked() Partition* partition = model->partitionForIndex( index ); Q_ASSERT( partition ); - if ( KPMHelpers::isPartitionNew( partition ) ) + if ( CalamaresUtils::Partition::isPartitionNew( partition ) ) updatePartitionToCreate( model->device(), partition ); else editExistingPartition( model->device(), partition ); @@ -452,7 +454,7 @@ PartitionPage::onPartitionViewActivated() // but I don't expect there will be other occurences of triggering the same // action from multiple UI elements in this page, so it does not feel worth // the price. - if ( KPMHelpers::isPartitionFreeSpace( partition ) ) + if ( CalamaresUtils::Partition::isPartitionFreeSpace( partition ) ) m_ui->createButton->click(); else m_ui->editButton->click(); diff --git a/src/modules/partition/gui/PartitionSplitterWidget.cpp b/src/modules/partition/gui/PartitionSplitterWidget.cpp index 62da1fe3d..bcc80b65a 100644 --- a/src/modules/partition/gui/PartitionSplitterWidget.cpp +++ b/src/modules/partition/gui/PartitionSplitterWidget.cpp @@ -21,8 +21,9 @@ #include "core/ColorUtils.h" #include "core/KPMHelpers.h" -#include "utils/Logger.h" #include "partition/PartitionIterator.h" +#include "partition/PartitionQuery.h" +#include "utils/Logger.h" #include "utils/CalamaresUtilsGui.h" @@ -69,7 +70,7 @@ PartitionSplitterWidget::init( Device* dev, bool drawNestedPartitions ) PartitionSplitterItem newItem = { ( *it )->partitionPath(), ColorUtils::colorForPartition( *it ), - KPMHelpers::isPartitionFreeSpace( *it ), + CalamaresUtils::Partition::isPartitionFreeSpace( *it ), ( *it )->capacity(), PartitionSplitterItem::Normal, {} diff --git a/src/modules/partition/tests/PartitionJobTests.cpp b/src/modules/partition/tests/PartitionJobTests.cpp index f3bd8dd13..28970e4b5 100644 --- a/src/modules/partition/tests/PartitionJobTests.cpp +++ b/src/modules/partition/tests/PartitionJobTests.cpp @@ -19,6 +19,7 @@ #include +#include "partition/PartitionQuery.h" #include "utils/Units.h" #include @@ -40,6 +41,7 @@ QTEST_GUILESS_MAIN( PartitionJobTests ) using namespace Calamares; using CalamaresUtils::operator""_MiB; +using CalamaresUtils::Partition::isPartitionFreeSpace; class PartitionMounter { @@ -115,7 +117,7 @@ static Partition* firstFreePartition( PartitionNode* parent ) { for( auto child : parent->children() ) - if ( KPMHelpers::isPartitionFreeSpace( child ) ) + if ( isPartitionFreeSpace( child ) ) return child; return nullptr; }