mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-28 18:05:36 -04:00
Add global checks for partition layout
This commit adds several checks while reading the configuration of the `partition` module, in case the partition layout configuration is misformed. If an error is encountered, an message is printed to the console and the module reverts to the default partition layout. Checks are also added when implementing the partition layout, in case a problem occurs that couldn't be anticipated (for example, when a partition size is in %, checking its absolute value require knowing the total device size, which is not the case when the configuration is being read). Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
parent
d32733bf59
commit
123222c0a8
3 changed files with 111 additions and 24 deletions
|
@ -43,14 +43,22 @@ public:
|
|||
QString partLabel;
|
||||
QString partMountPoint;
|
||||
FileSystem::Type partFileSystem = FileSystem::Unknown;
|
||||
PartUtils::PartSize partSize = PartUtils::PartSize(0, PartUtils::SizeUnit::Percent);
|
||||
PartUtils::PartSize partMinSize = PartUtils::PartSize(0, PartUtils::SizeUnit::Percent);
|
||||
PartUtils::PartSize partMaxSize = PartUtils::PartSize(100, PartUtils::SizeUnit::Percent);
|
||||
PartUtils::PartSize partSize;
|
||||
PartUtils::PartSize partMinSize;
|
||||
PartUtils::PartSize partMaxSize;
|
||||
|
||||
/// @brief All-zeroes PartitionEntry
|
||||
PartitionEntry() {}
|
||||
/// @brief Parse @p size, @p min and @p max to their respective member variables
|
||||
PartitionEntry( const QString& size, const QString& min, const QString& max );
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
if ( !partSize.isValid() ||
|
||||
( partMinSize.isValid() && partMaxSize.isValid() && partMinSize > partMaxSize ) )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
PartitionLayout();
|
||||
|
@ -58,9 +66,9 @@ public:
|
|||
PartitionLayout( const PartitionLayout& layout );
|
||||
~PartitionLayout();
|
||||
|
||||
void addEntry( PartitionEntry entry );
|
||||
void addEntry( const QString& mountPoint, const QString& size, const QString& min = QString(), const QString& max = QString() );
|
||||
void addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min = QString(), const QString& max = QString() );
|
||||
bool addEntry( PartitionEntry entry );
|
||||
bool addEntry( const QString& mountPoint, const QString& size, const QString& min = QString(), const QString& max = QString() );
|
||||
bool addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min = QString(), const QString& max = QString() );
|
||||
|
||||
/**
|
||||
* @brief Apply the current partition layout to the selected drive space.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue