[fsresizer] Calamares oding style
This commit is contained in:
parent
39902d1c3f
commit
21fedfce65
@ -49,11 +49,11 @@ ResizeFSJob::RelativeSize::RelativeSize()
|
||||
template<int N>
|
||||
void matchUnitSuffix(
|
||||
const QString& s,
|
||||
const char (&suffix)[N],
|
||||
const char ( &suffix )[N],
|
||||
ResizeFSJob::RelativeSize::Unit matchedUnit,
|
||||
int& value,
|
||||
ResizeFSJob::RelativeSize::Unit& unit
|
||||
)
|
||||
)
|
||||
{
|
||||
if ( s.endsWith( suffix ) )
|
||||
{
|
||||
@ -63,7 +63,7 @@ void matchUnitSuffix(
|
||||
}
|
||||
|
||||
|
||||
ResizeFSJob::RelativeSize::RelativeSize( const QString& s)
|
||||
ResizeFSJob::RelativeSize::RelativeSize( const QString& s )
|
||||
: m_value( 0 )
|
||||
, m_unit( None )
|
||||
{
|
||||
@ -82,14 +82,14 @@ ResizeFSJob::RelativeSize::RelativeSize( const QString& s)
|
||||
}
|
||||
|
||||
qint64
|
||||
ResizeFSJob::RelativeSize::apply( qint64 totalSectors , qint64 sectorSize )
|
||||
ResizeFSJob::RelativeSize::apply( qint64 totalSectors, qint64 sectorSize )
|
||||
{
|
||||
if ( !isValid() )
|
||||
return -1;
|
||||
if ( sectorSize < 1 )
|
||||
return -1;
|
||||
|
||||
switch( m_unit )
|
||||
switch ( m_unit )
|
||||
{
|
||||
case None:
|
||||
return -1;
|
||||
@ -138,14 +138,14 @@ ResizeFSJob::findPartition( CoreBackend* backend )
|
||||
cDebug() << "ResizeFSJob found" << devices.count() << "devices.";
|
||||
for ( DeviceList::iterator dev_it = devices.begin(); dev_it != devices.end(); ++dev_it )
|
||||
{
|
||||
if ( ! (*dev_it) )
|
||||
if ( ! ( *dev_it ) )
|
||||
continue;
|
||||
cDebug() << "ResizeFSJob found" << ( *dev_it )->deviceNode();
|
||||
for ( auto part_it = PartitionIterator::begin( *dev_it ); part_it != PartitionIterator::end( *dev_it ); ++part_it )
|
||||
{
|
||||
cDebug() << ".." << ( *part_it )->mountPoint() << "on" << ( *part_it )->deviceNode();
|
||||
if ( ( !m_fsname.isEmpty() && ( *part_it )->mountPoint() == m_fsname ) ||
|
||||
( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) )
|
||||
( !m_devicename.isEmpty() && ( *part_it )->deviceNode() == m_devicename ) )
|
||||
{
|
||||
cDebug() << ".. matched configuration dev=" << m_devicename << "fs=" << m_fsname;
|
||||
return PartitionMatch( *dev_it, *part_it );
|
||||
@ -166,7 +166,7 @@ ResizeFSJob::findPartition( CoreBackend* backend )
|
||||
* by occupied space after it).
|
||||
*/
|
||||
qint64
|
||||
ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m)
|
||||
ResizeFSJob::findGrownEnd( ResizeFSJob::PartitionMatch m )
|
||||
{
|
||||
if ( !m.first || !m.second )
|
||||
return -1; // Missing device data
|
||||
@ -195,7 +195,7 @@ ResizeFSJob::findGrownEnd(ResizeFSJob::PartitionMatch m)
|
||||
continue;
|
||||
}
|
||||
cDebug() << ".. comparing" << next_start << '-' << next_end;
|
||||
if ( (next_start > last_currently) && (next_start < last_available) )
|
||||
if ( ( next_start > last_currently ) && ( next_start < last_available ) )
|
||||
{
|
||||
cDebug() << " .. shrunk last available to" << next_start;
|
||||
last_available = next_start - 1; // Before that one starts
|
||||
@ -236,13 +236,12 @@ ResizeFSJob::exec()
|
||||
if ( !isValid() )
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Invalid configuration" ),
|
||||
tr( "The file-system resize job has an invalid configuration "
|
||||
"and will not run." ) );
|
||||
tr( "The file-system resize job has an invalid configuration and will not run." ) );
|
||||
|
||||
// Get KPMCore
|
||||
auto backend_p = CoreBackendManager::self()->backend();
|
||||
if ( backend_p )
|
||||
cDebug() << "KPMCore backend @" << (void *)backend_p << backend_p->id() << backend_p->version();
|
||||
cDebug() << "KPMCore backend @" << ( void* )backend_p << backend_p->id() << backend_p->version();
|
||||
else
|
||||
{
|
||||
cDebug() << "No KPMCore backend loaded yet";
|
||||
@ -271,8 +270,8 @@ ResizeFSJob::exec()
|
||||
if ( !m.first || !m.second )
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Resize Failed" ),
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and cannot be resized." ).arg(m_fsname)
|
||||
: tr( "The device %1 could not be found in this system, and cannot be resized." ).arg(m_devicename) );
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 could not be found in this system, and cannot be resized." ).arg( m_fsname )
|
||||
: tr( "The device %1 could not be found in this system, and cannot be resized." ).arg( m_devicename ) );
|
||||
|
||||
m.second->fileSystem().init(); // Initialize support for specific FS
|
||||
if ( !ResizeOperation::canGrow( m.second ) )
|
||||
@ -280,30 +279,30 @@ ResizeFSJob::exec()
|
||||
cDebug() << "canGrow() returned false.";
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Resize Failed" ),
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg(m_fsname)
|
||||
: tr( "The device %1 cannot be resized." ).arg(m_devicename) );
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg( m_fsname )
|
||||
: tr( "The device %1 cannot be resized." ).arg( m_devicename ) );
|
||||
}
|
||||
|
||||
qint64 new_end = findGrownEnd( m );
|
||||
cDebug() << "Resize from"
|
||||
<< m.second->firstSector() << '-' << m.second->lastSector()
|
||||
<< '(' << m.second->length() << ')'
|
||||
<< "to -" << new_end;
|
||||
<< m.second->firstSector() << '-' << m.second->lastSector()
|
||||
<< '(' << m.second->length() << ')'
|
||||
<< "to -" << new_end;
|
||||
|
||||
if ( new_end < 0 )
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Resize Failed" ),
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg(m_fsname)
|
||||
: tr( "The device %1 cannot be resized." ).arg(m_devicename) );
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 cannot be resized." ).arg( m_fsname )
|
||||
: tr( "The device %1 cannot be resized." ).arg( m_devicename ) );
|
||||
if ( new_end == 0 )
|
||||
{
|
||||
cWarning() << "Resize operation on" << m_fsname << m_devicename
|
||||
<< "skipped as not-useful.";
|
||||
<< "skipped as not-useful.";
|
||||
if ( m_required )
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Resize Failed" ),
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg(m_fsname)
|
||||
: tr( "The device %11 must be resized, but cannot" ).arg(m_fsname) );
|
||||
!m_fsname.isEmpty() ? tr( "The filesystem %1 must be resized, but cannot." ).arg( m_fsname )
|
||||
: tr( "The device %11 must be resized, but cannot" ).arg( m_fsname ) );
|
||||
|
||||
return Calamares::JobResult::ok();
|
||||
}
|
||||
@ -318,8 +317,8 @@ ResizeFSJob::exec()
|
||||
{
|
||||
cDebug() << "Resize failed." << op_report.output();
|
||||
return Calamares::JobResult::error(
|
||||
tr( "Resize Failed" ),
|
||||
op_report.toText() );
|
||||
tr( "Resize Failed" ),
|
||||
op_report.toText() );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user