[partition] Simplify and document ClearMounts

- note that the job indiscriminately closes all LUKS and LV
- don't hang on to lists we don't need
This commit is contained in:
Adriaan de Groot 2021-11-02 11:55:13 +01:00
parent 0253977778
commit 1410157356
2 changed files with 12 additions and 11 deletions

View File

@ -367,23 +367,17 @@ ClearMountsJob::prettyStatusMessage() const
Calamares::JobResult Calamares::JobResult
ClearMountsJob::exec() ClearMountsJob::exec()
{ {
CalamaresUtils::Partition::Syncer s;
const QString deviceName = m_deviceNode.split( '/' ).last(); const QString deviceName = m_deviceNode.split( '/' ).last();
CalamaresUtils::Partition::Syncer s;
QList< MessageAndPath > goodNews; QList< MessageAndPath > goodNews;
QProcess process;
const QStringList partitionsList = getPartitionsForDevice( deviceName );
const QStringList swapPartitions = getSwapsForDevice( m_deviceNode );
apply( getCryptoDevices(), tryCryptoClose, goodNews ); apply( getCryptoDevices(), tryCryptoClose, goodNews );
apply( getLVMVolumes(), tryUmount, goodNews ); apply( getLVMVolumes(), tryUmount, goodNews );
apply( getPVGroups( deviceName ), tryVGDisable, goodNews ); apply( getPVGroups( deviceName ), tryVGDisable, goodNews );
apply( getCryptoDevices(), tryCryptoClose, goodNews ); apply( getCryptoDevices(), tryCryptoClose, goodNews );
apply( partitionsList, tryUmount, goodNews ); apply( getPartitionsForDevice( deviceName ), tryUmount, goodNews );
apply( swapPartitions, tryClearSwap, goodNews ); apply( getSwapsForDevice( m_deviceNode ), tryClearSwap, goodNews );
Calamares::JobResult ok = Calamares::JobResult::ok(); Calamares::JobResult ok = Calamares::JobResult::ok();
ok.setMessage( tr( "Cleared all mounts for %1" ).arg( m_deviceNode ) ); ok.setMessage( tr( "Cleared all mounts for %1" ).arg( m_deviceNode ) );

View File

@ -17,14 +17,21 @@ class Device;
/** /**
* This job tries to free all mounts for the given device, so partitioning * This job tries to free all mounts for the given device, so partitioning
* operations can proceed. * operations can proceed.
*
* - partitions on the device are unmounted
* - swap on the device is disabled and cleared
* - physical volumes for LVM on the device are disabled
*
* In addition, regardless of device:
* - all /dev/mapper entries (crypto / LUKS) are closed
* - all logical volumes for LVM are unmounted
*
*/ */
class ClearMountsJob : public Calamares::Job class ClearMountsJob : public Calamares::Job
{ {
Q_OBJECT Q_OBJECT
public: public:
/** @brief Creates a job freeing mounts on @p device /** @brief Creates a job freeing mounts on @p device
*
* All /dev/mapper entries are closed, regardless of device.
* *
* No ownership is transferred; the @p device is used only to access * No ownership is transferred; the @p device is used only to access
* the device node (name). * the device node (name).