[partition] Simplify EFI-flags checking with KPMCore 4

This commit is contained in:
Adriaan de Groot 2020-11-04 01:16:36 +01:00
parent 85bb8c27b3
commit 15ace5202d

View File

@ -439,9 +439,13 @@ isEfiSystem()
bool bool
isEfiBootable( const Partition* candidate ) isEfiBootable( const Partition* candidate )
{ {
auto flags = PartitionInfo::flags( candidate ); const auto flags = PartitionInfo::flags( candidate );
cDebug() << "Check EFI bootable" << convenienceName( candidate ) << candidate->devicePath() << "flags" << flags;
// TODO: with KPMCore 4, this comment is wrong: the flags
// are remapped, and the ESP flag is the same as Boot.
#if defined( WITH_KPMCORE4API )
return flags.testFlag( KPM_PARTITION_FLAG_ESP );
#else
/* If bit 17 is set, old-style Esp flag, it's OK */ /* If bit 17 is set, old-style Esp flag, it's OK */
if ( flags.testFlag( KPM_PARTITION_FLAG_ESP ) ) if ( flags.testFlag( KPM_PARTITION_FLAG_ESP ) )
{ {
@ -471,10 +475,10 @@ isEfiBootable( const Partition* candidate )
if ( table->type() == PartitionTable::TableType::gpt ) if ( table->type() == PartitionTable::TableType::gpt )
{ {
const auto bootFlag = KPM_PARTITION_FLAG( Boot ); const auto bootFlag = KPM_PARTITION_FLAG( Boot );
cDebug() << Logger::SubEntry << "GPT table" << flags << "boot?" << bootFlag << flags.testFlag( bootFlag );
return flags.testFlag( bootFlag ); return flags.testFlag( bootFlag );
} }
return false; return false;
#endif
} }
QString QString