From e59b3e8bf5015f13f8b104984e7461c861977e62 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Thu, 20 Jun 2019 13:52:36 +0200 Subject: [PATCH] [libcalamares] Add unmount helper function --- src/libcalamares/partition/Mount.cpp | 11 ++++++++++- src/libcalamares/partition/Mount.h | 9 +++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/partition/Mount.cpp b/src/libcalamares/partition/Mount.cpp index c1e34b89b..fa7a49c0e 100644 --- a/src/libcalamares/partition/Mount.cpp +++ b/src/libcalamares/partition/Mount.cpp @@ -69,10 +69,19 @@ mount( const QString& devicePath, const QString& mountPoint, const QString& file args << "-o" << options; } - auto r = CalamaresUtils::System::instance()->runCommand( args, 10 ); + auto r = CalamaresUtils::System::runCommand( args, 10 ); sync(); return r.getExitCode(); } +int +unmount( const QString& path, const QStringList& options ) +{ + auto r = CalamaresUtils::System::runCommand( QStringList { "umount" } << options << path, 10 ); + sync(); + return r.getExitCode(); +} + + } // namespace Partition } // namespace CalamaresUtils diff --git a/src/libcalamares/partition/Mount.h b/src/libcalamares/partition/Mount.h index 18f65ef76..1053d85b0 100644 --- a/src/libcalamares/partition/Mount.h +++ b/src/libcalamares/partition/Mount.h @@ -23,6 +23,7 @@ #include "DllMacro.h" #include +#include namespace CalamaresUtils { @@ -44,6 +45,14 @@ DLLEXPORT int mount( const QString& devicePath, const QString& mountPoint, const QString& filesystemName = QString(), const QString& options = QString() ); + +/** @brief Unmount the given @p path (device or mount point). + * + * Runs umount(8) in the host system. + * + * @returns the program's exit codeor special codes like mount(). + */ +DLLEXPORT int unmount( const QString& path, const QStringList& options = QStringList() ); } // namespace Partition } // namespace CalamaresUtils