[partition] Improve logging in ClearMountsJob

- mark internal bits as static
- explain what is being looked-for

SEE #1817
SEE #1564
This commit is contained in:
Adriaan de Groot 2021-11-01 16:31:07 +01:00
parent 3f8078ea0f
commit 3e58639a68

View File

@ -29,28 +29,19 @@
using CalamaresUtils::Partition::PartitionIterator; using CalamaresUtils::Partition::PartitionIterator;
ClearMountsJob::ClearMountsJob( Device* device )
: Calamares::Job()
, m_device( device )
{
}
/** @brief Returns list of partitions on a given @p deviceName
QString *
ClearMountsJob::prettyName() const * The @p deviceName is a (whole-block) device, like "sda", and the partitions
{ * returned are then "sdaX". The whole-block device itself is ignored, if
return tr( "Clear mounts for partitioning operations on %1" ).arg( m_device->deviceNode() ); * present.
} *
* The format for /etc/partitions is, e.g.
* major minor #blocks name
QString * 8 0 33554422 sda
ClearMountsJob::prettyStatusMessage() const * 8 1 33554400 sda1
{ */
return tr( "Clearing mounts for partitioning operations on %1." ).arg( m_device->deviceNode() ); STATICTEST QStringList
}
QStringList
getPartitionsForDevice( const QString& deviceName ) getPartitionsForDevice( const QString& deviceName )
{ {
QStringList partitions; QStringList partitions;
@ -58,7 +49,7 @@ getPartitionsForDevice( const QString& deviceName )
QFile dev_partitions( "/proc/partitions" ); QFile dev_partitions( "/proc/partitions" );
if ( dev_partitions.open( QFile::ReadOnly ) ) if ( dev_partitions.open( QFile::ReadOnly ) )
{ {
cDebug() << "Reading from" << dev_partitions.fileName(); cDebug() << "Reading from" << dev_partitions.fileName() << "looking for" << deviceName;
QTextStream in( &dev_partitions ); QTextStream in( &dev_partitions );
(void)in.readLine(); // That's the header line, skip it (void)in.readLine(); // That's the header line, skip it
while ( !in.atEnd() ) while ( !in.atEnd() )
@ -81,6 +72,25 @@ getPartitionsForDevice( const QString& deviceName )
return partitions; return partitions;
} }
ClearMountsJob::ClearMountsJob( Device* device )
: Calamares::Job()
, m_device( device )
{
}
QString
ClearMountsJob::prettyName() const
{
return tr( "Clear mounts for partitioning operations on %1" ).arg( m_device->deviceNode() );
}
QString
ClearMountsJob::prettyStatusMessage() const
{
return tr( "Clearing mounts for partitioning operations on %1." ).arg( m_device->deviceNode() );
}
Calamares::JobResult Calamares::JobResult
ClearMountsJob::exec() ClearMountsJob::exec()
{ {