diff --git a/src/modules/partition/core/PartitionCoreModule.cpp b/src/modules/partition/core/PartitionCoreModule.cpp index 56b6281af..fde4c847f 100644 --- a/src/modules/partition/core/PartitionCoreModule.cpp +++ b/src/modules/partition/core/PartitionCoreModule.cpp @@ -55,6 +55,10 @@ #include #include +/** + * Does the given @p device contain the root filesystem? This is true if + * the device contains a partition which is currently mounted at / . + */ static bool hasRootPartition( Device* device ) { @@ -64,6 +68,19 @@ hasRootPartition( Device* device ) return false; } +static bool +isMounted( Device* device ) +{ + cDebug() << "Checking for mounted partitions in" << device->deviceNode(); + for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it ) + { + cDebug() << " .." << ( *it )->partitionPath() << "mount" << ( *it )->mountPoint(); + if ( ! ( *it )->mountPoint().isEmpty() ) + return true; + } + return false; +} + static bool isIso9660( const Device* device ) { @@ -162,9 +179,12 @@ PartitionCoreModule::doInit() // Remove the device which contains / from the list for ( DeviceList::iterator it = devices.begin(); it != devices.end(); ) - if ( ! ( *it ) || hasRootPartition( *it ) || - ( *it )->deviceNode().startsWith( "/dev/zram" ) || - isIso9660( *it ) ) + if ( ! ( *it ) || + hasRootPartition( *it ) || + isIso9660( *it ) || + isMounted( *it ) || + ( *it )->deviceNode().startsWith( "/dev/zram" ) + ) { cDebug() << " .. Winnowing" << ( ( *it ) ? ( *it )->deviceNode() : QString( "" ) ); it = devices.erase( it );