[partition] Add max size parameter

When using a custom partition layout with partition sizes in %, it can
be useful to set an upper limit to the partition size.

For instance, using a 20% size for the `/` partition will create a 24G
partition on a 120GB drive, but a 200GB partition on a 1TB drive, which
is not useful, and could be avoided by setting a maximum partition size.

This commit adds the `maxSize` parameter (with a default value of 100%).

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
This commit is contained in:
Arnaud Ferraris 2019-04-08 12:19:35 +02:00
parent fdb4311a70
commit 5358e2314d
4 changed files with 27 additions and 11 deletions

View file

@ -47,11 +47,13 @@ public:
PartUtils::SizeUnit partSizeUnit = PartUtils::SizeUnit::Percent;
double partMinSize = 0.0L;
PartUtils::SizeUnit partMinSizeUnit = PartUtils::SizeUnit::Percent;
double partMaxSize = 100.0L;
PartUtils::SizeUnit partMaxSizeUnit = PartUtils::SizeUnit::Percent;
/// @brief All-zeroes PartitionEntry
PartitionEntry() {};
/// @brief Parse @p size and @p min to their respective member variables
PartitionEntry( const QString& size, const QString& min );
/// @brief Parse @p size, @p min and @p max to their respective member variables
PartitionEntry( const QString& size, const QString& min, const QString& max );
};
PartitionLayout();
@ -60,8 +62,8 @@ public:
~PartitionLayout();
void addEntry( PartitionEntry entry );
void addEntry( const QString& mountPoint, const QString& size, const QString& min = QString() );
void addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min = QString() );
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() );
/**
* @brief Apply the current partition layout to the selected drive space.