[libcalamares] Introduce new function getPartitionTable
This commit is contained in:
parent
c963d8905f
commit
bf9c9a64f1
@ -16,6 +16,7 @@
|
||||
|
||||
#include <kpmcore/core/device.h>
|
||||
#include <kpmcore/core/partition.h>
|
||||
#include <kpmcore/core/partitiontable.h>
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
@ -26,6 +27,19 @@ namespace Partition
|
||||
using ::Device;
|
||||
using ::Partition;
|
||||
|
||||
const PartitionTable*
|
||||
getPartitionTable( const Partition* partition )
|
||||
{
|
||||
const PartitionNode* root = partition;
|
||||
while ( root && !root->isRoot() )
|
||||
{
|
||||
root = root->parent();
|
||||
}
|
||||
|
||||
return dynamic_cast< const PartitionTable* >( root );
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
isPartitionFreeSpace( const Partition* partition )
|
||||
{
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
class Device;
|
||||
class Partition;
|
||||
class PartitionTable;
|
||||
|
||||
namespace CalamaresUtils
|
||||
{
|
||||
@ -32,6 +33,10 @@ namespace Partition
|
||||
|
||||
using ::Device;
|
||||
using ::Partition;
|
||||
using ::PartitionTable;
|
||||
|
||||
/** @brief Get partition table */
|
||||
const PartitionTable* getPartitionTable( const Partition* partition );
|
||||
|
||||
/** @brief Is this a free-space area? */
|
||||
bool isPartitionFreeSpace( const Partition* );
|
||||
|
@ -454,20 +454,7 @@ isEfiBootable( const Partition* candidate )
|
||||
}
|
||||
|
||||
/* Otherwise, if it's a GPT table, Boot (bit 0) is the same as Esp */
|
||||
const PartitionNode* root = candidate;
|
||||
while ( root && !root->isRoot() )
|
||||
{
|
||||
root = root->parent();
|
||||
}
|
||||
|
||||
// Strange case: no root found, no partition table node?
|
||||
if ( !root )
|
||||
{
|
||||
cWarning() << "No root of partition table found.";
|
||||
return false;
|
||||
}
|
||||
|
||||
const PartitionTable* table = dynamic_cast< const PartitionTable* >( root );
|
||||
const PartitionTable* table = CalamaresUtils::Partition::getPartitionTable( candidate );
|
||||
if ( !table )
|
||||
{
|
||||
cWarning() << "Root of partition table is not a PartitionTable object";
|
||||
|
Loading…
Reference in New Issue
Block a user