2020-09-29 23:55:11 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2016-08-08 06:53:24 +01:00
|
|
|
|
|
|
|
#include "jobs/deactivatelogicalvolumejob.h"
|
|
|
|
|
|
|
|
#include "core/lvmdevice.h"
|
|
|
|
#include "core/partition.h"
|
|
|
|
#include "core/partitiontable.h"
|
|
|
|
|
|
|
|
#include "util/report.h"
|
|
|
|
|
|
|
|
#include <KLocalizedString>
|
|
|
|
|
|
|
|
/** Creates a new DeactivateLogicalVolumeJob
|
|
|
|
*/
|
2016-08-12 01:57:34 +01:00
|
|
|
DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& d, const QStringList lvPaths) :
|
2016-08-08 06:53:24 +01:00
|
|
|
Job(),
|
2016-08-12 01:57:34 +01:00
|
|
|
m_Device(d),
|
2016-08-08 06:53:24 +01:00
|
|
|
m_LVList(lvPaths)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool DeactivateLogicalVolumeJob::run(Report& parent)
|
|
|
|
{
|
|
|
|
bool rval = true;
|
|
|
|
|
|
|
|
Report* report = jobStarted(parent);
|
|
|
|
|
2018-04-09 02:57:45 +01:00
|
|
|
if (device().type() == Device::Type::LVM_Device) {
|
2016-08-08 20:45:41 +01:00
|
|
|
for (const auto &p : device().partitionTable()->children()) {
|
|
|
|
if (!p->roles().has(PartitionRole::Unallocated)) {
|
2016-08-11 15:51:52 +01:00
|
|
|
if (!LvmDevice::deactivateLV(*report, *p)) {
|
2016-08-08 06:53:24 +01:00
|
|
|
rval = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jobFinished(*report, rval);
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DeactivateLogicalVolumeJob::description() const
|
|
|
|
{
|
|
|
|
return xi18nc("@info/plain", "Deactivate Logical Volumes: <filename>%1</filename>", device().prettyDeviceNodeList());
|
|
|
|
}
|