partition: add checks for absolute minimum size of EFI

This commit is contained in:
Adriaan de Groot 2023-10-30 21:24:24 +01:00
parent b7545fded3
commit 026d1cb5e4
3 changed files with 30 additions and 1 deletions

View File

@ -528,6 +528,7 @@ PartitionViewStep::onLeave()
const bool okType = esp && PartUtils::isEfiFilesystemSuitableType( esp );
const bool okSize = esp && PartUtils::isEfiFilesystemSuitableSize( esp );
const bool okMinimumSize = esp && PartUtils::isEfiFilesystemSuitableMinimumSize( esp );
const bool okFlag = esp && PartUtils::isEfiBootable( esp );
if ( !esp )

View File

@ -485,7 +485,29 @@ isEfiFilesystemSuitableSize( const Partition* candidate )
}
else
{
cWarning() << "Filesystem for EFI is too small (" << size << "bytes)";
cWarning() << "Filesystem for EFI is smaller than recommended (" << size << "bytes)";
return false;
}
}
bool
isEfiFilesystemSuitableMinimumSize( const Partition* candidate )
{
using Calamares::Units::operator""_MiB;
auto size = candidate->capacity(); // bytes
if ( size <= 0 )
{
return false;
}
if ( size >= 32_MiB )
{
return true;
}
else
{
cWarning() << "Filesystem for EFI is below minimum (" << size << "bytes)";
return false;
}
}

View File

@ -99,6 +99,12 @@ bool isEfiFilesystemSuitableType( const Partition* candidate );
*/
bool isEfiFilesystemSuitableSize( const Partition* candidate );
/**
* @brief Is the @p candidate suitable as an EFI boot partition?
* This checks the bonkers-small minimum of 32MiB.
*/
bool isEfiFilesystemSuitableMinimumSize( const Partition* candidate );
/** @brief Returns the minimum size of an EFI boot partition in bytes.
*
* This is determined as 300MiB, based on the FAT32 standard