diff --git a/src/modules/partition/tests/ClearMountsJobTests.cpp b/src/modules/partition/tests/ClearMountsJobTests.cpp index 4382d09d8..c74c1f25b 100644 --- a/src/modules/partition/tests/ClearMountsJobTests.cpp +++ b/src/modules/partition/tests/ClearMountsJobTests.cpp @@ -34,6 +34,28 @@ getPartitionsForDevice_other(const QString& deviceName) { QStringList partitions; + QFile dev_partitions( "/proc/partitions" ); + 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 partitions; }