From 23eabd74c6b83b0663afb2743b779732690d1baf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 2 Nov 2020 16:01:10 +0100 Subject: [PATCH] [partition] Set FS type explicitly if no layout is given - the "simple" constructor for PartitionEntry left the FS type set as the constructor left it -- which is Unknown by default. This leads to install failures in systems that don't set a special layout but just want a single / -- because the FS is set to Unknown. - massage the constructor and consumer of the code, push Ext4 FS in the tests and use the configured default in production. --- src/modules/partition/core/PartitionLayout.cpp | 7 ++++--- src/modules/partition/core/PartitionLayout.h | 9 +++++++-- src/modules/partition/tests/CreateLayoutsTests.cpp | 12 ++++++------ 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/modules/partition/core/PartitionLayout.cpp b/src/modules/partition/core/PartitionLayout.cpp index 85ba683d0..b71512685 100644 --- a/src/modules/partition/core/PartitionLayout.cpp +++ b/src/modules/partition/core/PartitionLayout.cpp @@ -63,8 +63,9 @@ PartitionLayout::PartitionEntry::PartitionEntry() { } -PartitionLayout::PartitionEntry::PartitionEntry( const QString& mountPoint, const QString& size, const QString& minSize, const QString& maxSize ) - : partAttributes( 0 ) +PartitionLayout::PartitionEntry::PartitionEntry( FileSystem::Type type, const QString& mountPoint, const QString& size, const QString& minSize, const QString& maxSize ) + : partType( type ) + , partAttributes( 0 ) , partMountPoint( mountPoint ) , partSize( size ) , partMinSize( minSize ) @@ -148,7 +149,7 @@ PartitionLayout::init( const QVariantList& config ) if ( !m_partLayout.count() ) { - addEntry( { QString( "/" ), QString( "100%" ) } ); + addEntry( { m_defaultFsType, QString( "/" ), QString( "100%" ) } ); } } diff --git a/src/modules/partition/core/PartitionLayout.h b/src/modules/partition/core/PartitionLayout.h index e54f28b63..8c02a8a41 100644 --- a/src/modules/partition/core/PartitionLayout.h +++ b/src/modules/partition/core/PartitionLayout.h @@ -44,8 +44,13 @@ public: /// @brief All-zeroes PartitionEntry PartitionEntry(); - /// @brief Parse @p mountPoint, @p size, @p minSize and @p maxSize to their respective member variables - PartitionEntry( const QString& mountPoint, + /** @brief Parse @p mountPoint, @p size, @p minSize and @p maxSize to their respective member variables + * + * Sets a specific FS type (not parsed from string like the other + * constructor). + */ + PartitionEntry( FileSystem::Type type, + const QString& mountPoint, const QString& size, const QString& minSize = QString(), const QString& maxSize = QString() ); diff --git a/src/modules/partition/tests/CreateLayoutsTests.cpp b/src/modules/partition/tests/CreateLayoutsTests.cpp index 4b76bb83a..04a06b2b3 100644 --- a/src/modules/partition/tests/CreateLayoutsTests.cpp +++ b/src/modules/partition/tests/CreateLayoutsTests.cpp @@ -59,7 +59,7 @@ CreateLayoutsTests::testFixedSizePartition() PartitionRole role( PartitionRole::Role::Any ); QList< Partition* > partitions; - if ( !layout.addEntry( { QString( "/" ), QString( "5MiB" ) } ) ) + if ( !layout.addEntry( { FileSystem::Type::Ext4, QString( "/" ), QString( "5MiB" ) } ) ) { QFAIL( qPrintable( "Unable to create / partition" ) ); } @@ -79,7 +79,7 @@ CreateLayoutsTests::testPercentSizePartition() PartitionRole role( PartitionRole::Role::Any ); QList< Partition* > partitions; - if ( !layout.addEntry( { QString( "/" ), QString( "50%" ) } ) ) + if ( !layout.addEntry( { FileSystem::Type::Ext4, QString( "/" ), QString( "50%" ) } ) ) { QFAIL( qPrintable( "Unable to create / partition" ) ); } @@ -99,17 +99,17 @@ CreateLayoutsTests::testMixedSizePartition() PartitionRole role( PartitionRole::Role::Any ); QList< Partition* > partitions; - if ( !layout.addEntry( { QString( "/" ), QString( "5MiB" ) } ) ) + if ( !layout.addEntry( { FileSystem::Type::Ext4, QString( "/" ), QString( "5MiB" ) } ) ) { QFAIL( qPrintable( "Unable to create / partition" ) ); } - if ( !layout.addEntry( { QString( "/home" ), QString( "50%" ) } ) ) + if ( !layout.addEntry( { FileSystem::Type::Ext4, QString( "/home" ), QString( "50%" ) } ) ) { QFAIL( qPrintable( "Unable to create /home partition" ) ); } - if ( !layout.addEntry( { QString( "/bkup" ), QString( "50%" ) } ) ) + if ( !layout.addEntry( { FileSystem::Type::Ext4, QString( "/bkup" ), QString( "50%" ) } ) ) { QFAIL( qPrintable( "Unable to create /bkup partition" ) ); } @@ -124,7 +124,7 @@ CreateLayoutsTests::testMixedSizePartition() } #ifdef WITH_KPMCORE4API -// TODO: Get a clean way to instanciate a test Device from KPMCore +// TODO: Get a clean way to instantiate a test Device from KPMCore class DevicePrivate { public: