[partition] Use TemporaryMount support class
- While here, fix up compile warning - add -R to umount for good measure
This commit is contained in:
parent
dd0adeb3bb
commit
ba7259d9ee
@ -96,7 +96,7 @@ TemporaryMount::~TemporaryMount()
|
|||||||
{
|
{
|
||||||
if ( m_valid )
|
if ( m_valid )
|
||||||
{
|
{
|
||||||
unmount( m_devicePath );
|
unmount( m_devicePath, { "-R" } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ DLLEXPORT int mount( const QString& devicePath,
|
|||||||
*/
|
*/
|
||||||
DLLEXPORT int unmount( const QString& path, const QStringList& options = QStringList() );
|
DLLEXPORT int unmount( const QString& path, const QStringList& options = QStringList() );
|
||||||
|
|
||||||
DLLEXPORT class TemporaryMount
|
class DLLEXPORT TemporaryMount
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TemporaryMount( const QString& devicePath,
|
TemporaryMount( const QString& devicePath,
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include "GlobalStorage.h"
|
#include "GlobalStorage.h"
|
||||||
#include "JobQueue.h"
|
#include "JobQueue.h"
|
||||||
|
#include "partition/Mount.h"
|
||||||
#include "partition/PartitionIterator.h"
|
#include "partition/PartitionIterator.h"
|
||||||
#include "partition/PartitionQuery.h"
|
#include "partition/PartitionQuery.h"
|
||||||
#include "utils/CalamaresUtilsSystem.h"
|
#include "utils/CalamaresUtilsSystem.h"
|
||||||
@ -248,8 +249,8 @@ lookForFstabEntries( const QString& partitionPath )
|
|||||||
QTemporaryDir mountsDir;
|
QTemporaryDir mountsDir;
|
||||||
mountsDir.setAutoRemove( false );
|
mountsDir.setAutoRemove( false );
|
||||||
|
|
||||||
int exit = QProcess::execute( "mount", { "-o", mountOptions.join(','), partitionPath, mountsDir.path() } );
|
CalamaresUtils::Partition::TemporaryMount mount( partitionPath, mountsDir.path(), QString(), mountOptions.join(',') );
|
||||||
if ( !exit ) // if all is well
|
if ( mount.isValid() )
|
||||||
{
|
{
|
||||||
QFile fstabFile( mountsDir.path() + "/etc/fstab" );
|
QFile fstabFile( mountsDir.path() + "/etc/fstab" );
|
||||||
|
|
||||||
@ -269,9 +270,6 @@ lookForFstabEntries( const QString& partitionPath )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
cWarning() << "Could not read fstab from mounted fs";
|
cWarning() << "Could not read fstab from mounted fs";
|
||||||
|
|
||||||
if ( QProcess::execute( "umount", { "-R", mountsDir.path() } ) )
|
|
||||||
cWarning() << "Could not unmount" << mountsDir.path();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cWarning() << "Could not mount existing fs";
|
cWarning() << "Could not mount existing fs";
|
||||||
|
Loading…
Reference in New Issue
Block a user