mirror of
https://github.com/parchlinux/calamares.git
synced 2025-07-01 11:25:36 -04:00
[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:
parent
fdb4311a70
commit
5358e2314d
4 changed files with 27 additions and 11 deletions
|
@ -75,17 +75,19 @@ PartitionLayout::addEntry( PartitionLayout::PartitionEntry entry )
|
|||
m_partLayout.append( entry );
|
||||
}
|
||||
|
||||
PartitionLayout::PartitionEntry::PartitionEntry(const QString& size, const QString& min)
|
||||
PartitionLayout::PartitionEntry::PartitionEntry( const QString& size, const QString& min, const QString& max )
|
||||
{
|
||||
partSize = PartUtils::parseSizeString( size , &partSizeUnit );
|
||||
if ( !min.isEmpty() )
|
||||
partMinSize = PartUtils::parseSizeString( min , &partMinSizeUnit );
|
||||
if ( !max.isEmpty() )
|
||||
partMaxSize = PartUtils::parseSizeString( max , &partMaxSizeUnit );
|
||||
}
|
||||
|
||||
void
|
||||
PartitionLayout::addEntry( const QString& mountPoint, const QString& size, const QString& min )
|
||||
PartitionLayout::addEntry( const QString& mountPoint, const QString& size, const QString& min, const QString& max )
|
||||
{
|
||||
PartitionLayout::PartitionEntry entry( size, min );
|
||||
PartitionLayout::PartitionEntry entry( size, min, max );
|
||||
|
||||
entry.partMountPoint = mountPoint;
|
||||
entry.partFileSystem = m_defaultFsType;
|
||||
|
@ -94,9 +96,9 @@ PartitionLayout::addEntry( const QString& mountPoint, const QString& size, const
|
|||
}
|
||||
|
||||
void
|
||||
PartitionLayout::addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min )
|
||||
PartitionLayout::addEntry( const QString& label, const QString& mountPoint, const QString& fs, const QString& size, const QString& min, const QString& max )
|
||||
{
|
||||
PartitionLayout::PartitionEntry entry( size, min );
|
||||
PartitionLayout::PartitionEntry entry( size, min, max );
|
||||
|
||||
entry.partLabel = label;
|
||||
entry.partMountPoint = mountPoint;
|
||||
|
@ -114,7 +116,7 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||
const PartitionRole& role )
|
||||
{
|
||||
QList< Partition* > partList;
|
||||
qint64 size, minSize, end;
|
||||
qint64 size, minSize, maxSize, end;
|
||||
qint64 totalSize = lastSector - firstSector + 1;
|
||||
qint64 availableSize = totalSize;
|
||||
|
||||
|
@ -128,8 +130,11 @@ PartitionLayout::execute( Device *dev, qint64 firstSector,
|
|||
// Calculate partition size
|
||||
size = PartUtils::sizeToSectors( part.partSize, part.partSizeUnit, totalSize, dev->logicalSize() );
|
||||
minSize = PartUtils::sizeToSectors( part.partMinSize, part.partMinSizeUnit, totalSize, dev->logicalSize() );
|
||||
maxSize = PartUtils::sizeToSectors( part.partMaxSize, part.partMaxSizeUnit, totalSize, dev->logicalSize() );
|
||||
if ( size < minSize )
|
||||
size = minSize;
|
||||
if ( size > maxSize )
|
||||
size = maxSize;
|
||||
if ( size > availableSize )
|
||||
size = availableSize;
|
||||
end = firstSector + size - 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue