[partition] Introduce function for checking various flag-combinations for ESP boot.

main
Adriaan de Groot 7 years ago
parent 3ff68bce98
commit 94b6c95c44

@ -340,4 +340,26 @@ isEfiSystem()
return QDir( "/sys/firmware/efi/efivars" ).exists();
}
bool
isEfiBootable( const Partition* candidate )
{
/* If bit 17 is set, old-style Esp flag, it's OK */
if ( candidate->activeFlags().testFlag( PartitionTable::FlagEsp ) )
return true;
/* 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 )
return false;
const PartitionTable* table = dynamic_cast<const PartitionTable*>( root );
return table && ( table->type() == PartitionTable::TableType::gpt ) &&
candidate->activeFlags().testFlag( PartitionTable::FlagBoot );
}
} // nmamespace PartUtils

@ -67,6 +67,11 @@ OsproberEntryList runOsprober( PartitionCoreModule* core );
*/
bool isEfiSystem();
/**
* @brief Is the given @p partition bootable in EFI? Depending on
* the partition table layout, this may mean different flags.
*/
bool isEfiBootable( const Partition* candidate );
}
#endif // PARTUTILS_H

Loading…
Cancel
Save