diff --git a/src/modules/fsresizer/ResizeFSJob.cpp b/src/modules/fsresizer/ResizeFSJob.cpp index 0589e1866..254e80adb 100644 --- a/src/modules/fsresizer/ResizeFSJob.cpp +++ b/src/modules/fsresizer/ResizeFSJob.cpp @@ -33,6 +33,7 @@ #include "JobQueue.h" #include "GlobalStorage.h" +#include "utils/CalamaresUtils.h" #include "utils/Logger.h" #include "utils/Units.h" @@ -68,7 +69,7 @@ ResizeFSJob::RelativeSize::RelativeSize( const QString& s) { matchUnitSuffix( s, "%", Percent, m_value, m_unit ); matchUnitSuffix( s, "MiB", Absolute, m_value, m_unit ); - + if ( ( unit() == Percent ) && ( value() > 100 ) ) { cDebug() << "Percent value" << value() << "is not valid."; @@ -87,7 +88,7 @@ ResizeFSJob::RelativeSize::apply( qint64 totalSectors , qint64 sectorSize ) return -1; if ( sectorSize < 1 ) return -1; - + switch( m_unit ) { case None: @@ -113,6 +114,7 @@ ResizeFSJob::RelativeSize::apply( Device* d ) ResizeFSJob::ResizeFSJob( QObject* parent ) : Calamares::CppJob( parent ) + , m_required( false ) { } @@ -156,7 +158,7 @@ ResizeFSJob::findPartition( CoreBackend* backend ) } /** @brief Returns the last sector the matched partition should occupy. - * + * * Returns a sector number. Returns -1 if something is wrong (e.g. * can't resize at all, or missing data). Returns 0 if the resize * won't fit because it doesn't satisfy the settings for atleast @@ -223,7 +225,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m) cDebug() << ".. only growing by" << wanted << "instead of full" << expand; last_available -= ( expand - wanted ); } - + return last_available; } @@ -300,7 +302,7 @@ ResizeFSJob::exec() << "skipped as not-useful."; return Calamares::JobResult::ok(); } - + if ( ( new_end > 0 ) && ( new_end > m.second->lastSector() ) ) { ResizeOperation op( *m.first, *m.second, m.second->firstSector(), new_end ); @@ -334,6 +336,8 @@ ResizeFSJob::setConfigurationMap( const QVariantMap& configurationMap ) m_size = RelativeSize( configurationMap["size"].toString() ); m_atleast = RelativeSize( configurationMap["atleast"].toString() ); + + m_required = CalamaresUtils::getBool( configurationMap, "required", false ); } CALAMARES_PLUGIN_FACTORY_DEFINITION( ResizeFSJobFactory, registerPlugin(); ) diff --git a/src/modules/fsresizer/ResizeFSJob.h b/src/modules/fsresizer/ResizeFSJob.h index 063495e7d..c34ccb865 100644 --- a/src/modules/fsresizer/ResizeFSJob.h +++ b/src/modules/fsresizer/ResizeFSJob.h @@ -68,19 +68,19 @@ public: * * Each sector has size @p sectorSize , for converting absolute * sizes in MiB to sector counts. - * + * * For invalid sizes, returns -1. * For absolute sizes, returns the number of sectors needed. * For percent sizes, returns that percent of the number of sectors. */ qint64 apply( qint64 totalSectors, qint64 sectorSize ); - + /** @brief Apply this size to the given device. - * + * * Equivalent to apply( d->totalLogical(), d->logicalSize() ) */ qint64 apply( Device* d ); - + private: int m_value; Unit m_unit; @@ -107,6 +107,7 @@ private: RelativeSize m_atleast; QString m_fsname; // Either this, or devicename, is set, not both QString m_devicename; + bool m_required; using PartitionMatch = QPair; /** @brief Find the configured FS using KPMCore @p backend */ diff --git a/src/modules/fsresizer/fsresizer.conf b/src/modules/fsresizer/fsresizer.conf index 06141fc7d..33329248d 100644 --- a/src/modules/fsresizer/fsresizer.conf +++ b/src/modules/fsresizer/fsresizer.conf @@ -12,7 +12,7 @@ # Which FS needs to be grown? Choose one way to identify it: # - *fs* names a mount point which should already be mounted # in the system. -# - *dev* names a device +# - *dev* names a device fs: / # dev: /dev/mmcblk0p1 @@ -33,5 +33,17 @@ size: 100% # size, as above. If missing, then it's assumed to be 0, # which means resizing is always worthwhile. # +# If *atleast* is not zero, then the setting *required*, +# below, becomes relevant. +# # Percentages apply to **total device size**. -atleast: 1000MiB +#atleast: 1000MiB + +# When *atleast* is not zero, then the resize may be +# recommended (the default) or **required**. If the +# resize is required and cannot be carried out (because +# there's not enough space), then that is a fatal +# error for the installer. By default, resize is only +# recommended and it is not an error for no resize to be +# carried out. +required: false