From 948c078e1a11d86d7f06aa2ba8968cd4869c3c85 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jul 2020 23:03:12 +0200 Subject: [PATCH 1/4] [partition] winnow floppy drives - don't list floppy drives FIXES #1393 --- src/modules/partition/core/DeviceList.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index 944940d9a..1eb7d26eb 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -92,6 +92,19 @@ isIso9660( const Device* device ) return false; } +static inline bool +isZRam( const Device* device ) +{ + const QString path = device->deviceNode(); + return path.startswith( "/dev/zram" ); +} + +static inline bool +isFloppyDrive( const Device* device ) +{ + const QString path = device->deviceNode(); + return path.startswith( "/dev/fd" ) || path.startswith( "/dev/floppy" ); +} static inline QDebug& operator<<( QDebug& s, QList< Device* >::iterator& it ) @@ -138,11 +151,16 @@ getDevices( DeviceType which, qint64 minimumSize ) cDebug() << Logger::SubEntry << "Skipping nullptr device"; it = erase( devices, it ); } - else if ( ( *it )->deviceNode().startsWith( "/dev/zram" ) ) + else if ( isZRam( *it ) ) { cDebug() << Logger::SubEntry << "Removing zram" << it; it = erase( devices, it ); } + else if ( isFloppyDrive( ( *it ) ) ) + { + cDebug() << Logger::SubEntry << "Removing floppy disk" << it; + it = erase( devices, it ); + } else if ( writableOnly && hasRootPartition( *it ) ) { cDebug() << Logger::SubEntry << "Removing device with root filesystem (/) on it" << it; From 313531bc4b7954c070f842c3ea223838151ed221 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jul 2020 23:04:39 +0200 Subject: [PATCH 2/4] [partition] Remove unused parameter - there are no consumers for checking-the-capacity-of-the-drive This parameter was introduced in 3cd18fd285 as "preparatory work" but never completed. The architecture of the PartitionCoreModule makes it very difficult to get the necessary parameters to the right place, and it would probably be better to put a SortFilterProxyModel in front of a partitioning model anyway. Since the display code can already filter on size, just drop this one. --- src/modules/partition/core/DeviceList.cpp | 7 +------ src/modules/partition/core/DeviceList.h | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index 1eb7d26eb..72786d5a5 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -125,7 +125,7 @@ erase( DeviceList& l, DeviceList::iterator& it ) } QList< Device* > -getDevices( DeviceType which, qint64 minimumSize ) +getDevices( DeviceType which ) { bool writableOnly = ( which == DeviceType::WritableOnly ); @@ -171,11 +171,6 @@ getDevices( DeviceType which, qint64 minimumSize ) cDebug() << Logger::SubEntry << "Removing device with iso9660 filesystem (probably a CD) on it" << it; it = erase( devices, it ); } - else if ( ( minimumSize >= 0 ) && !( ( *it )->capacity() > minimumSize ) ) - { - cDebug() << Logger::SubEntry << "Removing too-small" << it; - it = erase( devices, it ); - } else { ++it; diff --git a/src/modules/partition/core/DeviceList.h b/src/modules/partition/core/DeviceList.h index 6823d6951..51c71feeb 100644 --- a/src/modules/partition/core/DeviceList.h +++ b/src/modules/partition/core/DeviceList.h @@ -45,7 +45,7 @@ enum class DeviceType * greater than @p minimumSize will be returned. * @return a list of Devices meeting this criterium. */ -QList< Device* > getDevices( DeviceType which = DeviceType::All, qint64 minimumSize = -1 ); +QList< Device* > getDevices( DeviceType which = DeviceType::All ); } // namespace PartUtils From 7f1a59f02b207269916a5975b1672655fd371b59 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jul 2020 23:46:51 +0200 Subject: [PATCH 3/4] [partition] Fix typo --- src/modules/partition/core/DeviceList.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/partition/core/DeviceList.cpp b/src/modules/partition/core/DeviceList.cpp index 72786d5a5..041801b9e 100644 --- a/src/modules/partition/core/DeviceList.cpp +++ b/src/modules/partition/core/DeviceList.cpp @@ -96,14 +96,14 @@ static inline bool isZRam( const Device* device ) { const QString path = device->deviceNode(); - return path.startswith( "/dev/zram" ); + return path.startsWith( "/dev/zram" ); } static inline bool isFloppyDrive( const Device* device ) { const QString path = device->deviceNode(); - return path.startswith( "/dev/fd" ) || path.startswith( "/dev/floppy" ); + return path.startsWith( "/dev/fd" ) || path.startsWith( "/dev/floppy" ); } static inline QDebug& From 240c703549c7f073590dc45783154c80f73903d4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 8 Jul 2020 11:12:27 +0200 Subject: [PATCH 4/4] [partition] Don't leak the PM core object --- src/modules/partition/gui/PartitionViewStep.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/partition/gui/PartitionViewStep.cpp b/src/modules/partition/gui/PartitionViewStep.cpp index a583a4b96..b0142a82a 100644 --- a/src/modules/partition/gui/PartitionViewStep.cpp +++ b/src/modules/partition/gui/PartitionViewStep.cpp @@ -122,6 +122,7 @@ PartitionViewStep::~PartitionViewStep() { m_manualPartitionPage->deleteLater(); } + delete m_core; }