From ba7259d9ee03f2f4e23690937892566b1b5c905e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Jun 2019 14:49:44 +0200 Subject: [PATCH] [partition] Use TemporaryMount support class - While here, fix up compile warning - add -R to umount for good measure --- src/libcalamares/partition/Mount.cpp | 2 +- src/libcalamares/partition/Mount.h | 2 +- src/modules/partition/core/PartUtils.cpp | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/libcalamares/partition/Mount.cpp b/src/libcalamares/partition/Mount.cpp index 12c9f0d7c..0ab0e26bc 100644 --- a/src/libcalamares/partition/Mount.cpp +++ b/src/libcalamares/partition/Mount.cpp @@ -96,7 +96,7 @@ TemporaryMount::~TemporaryMount() { if ( m_valid ) { - unmount( m_devicePath ); + unmount( m_devicePath, { "-R" } ); } } diff --git a/src/libcalamares/partition/Mount.h b/src/libcalamares/partition/Mount.h index 58b049093..67e310ac3 100644 --- a/src/libcalamares/partition/Mount.h +++ b/src/libcalamares/partition/Mount.h @@ -54,7 +54,7 @@ DLLEXPORT int mount( const QString& devicePath, */ DLLEXPORT int unmount( const QString& path, const QStringList& options = QStringList() ); -DLLEXPORT class TemporaryMount +class DLLEXPORT TemporaryMount { public: TemporaryMount( const QString& devicePath, diff --git a/src/modules/partition/core/PartUtils.cpp b/src/modules/partition/core/PartUtils.cpp index 093f2720b..e77046b48 100644 --- a/src/modules/partition/core/PartUtils.cpp +++ b/src/modules/partition/core/PartUtils.cpp @@ -28,6 +28,7 @@ #include "GlobalStorage.h" #include "JobQueue.h" +#include "partition/Mount.h" #include "partition/PartitionIterator.h" #include "partition/PartitionQuery.h" #include "utils/CalamaresUtilsSystem.h" @@ -248,8 +249,8 @@ lookForFstabEntries( const QString& partitionPath ) QTemporaryDir mountsDir; mountsDir.setAutoRemove( false ); - int exit = QProcess::execute( "mount", { "-o", mountOptions.join(','), partitionPath, mountsDir.path() } ); - if ( !exit ) // if all is well + CalamaresUtils::Partition::TemporaryMount mount( partitionPath, mountsDir.path(), QString(), mountOptions.join(',') ); + if ( mount.isValid() ) { QFile fstabFile( mountsDir.path() + "/etc/fstab" ); @@ -269,9 +270,6 @@ lookForFstabEntries( const QString& partitionPath ) } else cWarning() << "Could not read fstab from mounted fs"; - - if ( QProcess::execute( "umount", { "-R", mountsDir.path() } ) ) - cWarning() << "Could not unmount" << mountsDir.path(); } else cWarning() << "Could not mount existing fs";