[partition] Swap the two implementations of getting partitions
This commit is contained in:
parent
f2438a5bf4
commit
399919c49a
@ -63,20 +63,31 @@ ClearMountsJob::prettyStatusMessage() const
|
|||||||
QStringList
|
QStringList
|
||||||
getPartitionsForDevice( const QString& deviceName )
|
getPartitionsForDevice( const QString& deviceName )
|
||||||
{
|
{
|
||||||
QProcess process;
|
QStringList partitions;
|
||||||
process.setProgram( "sh" );
|
|
||||||
process.setArguments( {
|
|
||||||
"-c",
|
|
||||||
QString( "echo $(awk '{print $4}' /proc/partitions | sed -e '/name/d' -e '/^$/d' -e '/[1-9]/!d' | grep %1)" )
|
|
||||||
.arg( deviceName )
|
|
||||||
} );
|
|
||||||
process.start();
|
|
||||||
process.waitForFinished();
|
|
||||||
|
|
||||||
const QString partitions = process.readAllStandardOutput();
|
QFile dev_partitions( "/proc/partitions" );
|
||||||
const QStringList partitionsList = partitions.simplified().split( ' ' );
|
if ( dev_partitions.open( QFile::ReadOnly ) )
|
||||||
|
{
|
||||||
|
cDebug() << "Reading from" << dev_partitions.fileName();
|
||||||
|
QTextStream in( &dev_partitions );
|
||||||
|
(void) in.readLine(); // That's the header line, skip it
|
||||||
|
while ( !in.atEnd() )
|
||||||
|
{
|
||||||
|
// The fourth column (index from 0, so index 3) is the name of the device;
|
||||||
|
// keep it if it is followed by something.
|
||||||
|
QStringList columns = in.readLine().split( ' ', QString::SkipEmptyParts );
|
||||||
|
if ( ( columns.count() >= 4 ) && ( columns[3].startsWith( deviceName ) ) && ( columns[3] != deviceName ) )
|
||||||
|
{
|
||||||
|
partitions.append( columns[3] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cDebug() << "Could not open" << dev_partitions.fileName();
|
||||||
|
}
|
||||||
|
|
||||||
return partitionsList;
|
return partitions;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calamares::JobResult
|
Calamares::JobResult
|
||||||
|
@ -32,31 +32,20 @@ getPartitionsForDevice( const QString& deviceName );
|
|||||||
QStringList
|
QStringList
|
||||||
getPartitionsForDevice_other(const QString& deviceName)
|
getPartitionsForDevice_other(const QString& deviceName)
|
||||||
{
|
{
|
||||||
QStringList partitions;
|
QProcess process;
|
||||||
|
process.setProgram( "sh" );
|
||||||
|
process.setArguments( {
|
||||||
|
"-c",
|
||||||
|
QString( "echo $(awk '{print $4}' /proc/partitions | sed -e '/name/d' -e '/^$/d' -e '/[1-9]/!d' | grep %1)" )
|
||||||
|
.arg( deviceName )
|
||||||
|
} );
|
||||||
|
process.start();
|
||||||
|
process.waitForFinished();
|
||||||
|
|
||||||
QFile dev_partitions( "/proc/partitions" );
|
const QString partitions = process.readAllStandardOutput();
|
||||||
if ( dev_partitions.open( QFile::ReadOnly ) )
|
const QStringList partitionsList = partitions.simplified().split( ' ' );
|
||||||
{
|
|
||||||
cDebug() << "Reading from" << dev_partitions.fileName();
|
|
||||||
QTextStream in( &dev_partitions );
|
|
||||||
(void) in.readLine(); // That's the header line, skip it
|
|
||||||
while ( !in.atEnd() )
|
|
||||||
{
|
|
||||||
// The fourth column (index from 0, so index 3) is the name of the device;
|
|
||||||
// keep it if it is followed by something.
|
|
||||||
QStringList columns = in.readLine().split( ' ', QString::SkipEmptyParts );
|
|
||||||
if ( ( columns.count() >= 4 ) && ( columns[3].startsWith( deviceName ) ) && ( columns[3] != deviceName ) )
|
|
||||||
{
|
|
||||||
partitions.append( columns[3] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
cDebug() << "Could not open" << dev_partitions.fileName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return partitions;
|
return partitionsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user