File indexing completed on 2024-04-28 05:45:53
0001 /* 0002 SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com> 0003 SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu> 0004 0005 SPDX-License-Identifier: GPL-3.0-or-later 0006 */ 0007 0008 #include "jobs/deactivatelogicalvolumejob.h" 0009 0010 #include "core/lvmdevice.h" 0011 #include "core/partition.h" 0012 #include "core/partitiontable.h" 0013 0014 #include "util/report.h" 0015 0016 #include <KLocalizedString> 0017 0018 /** Creates a new DeactivateLogicalVolumeJob 0019 */ 0020 DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& d, const QStringList lvPaths) : 0021 Job(), 0022 m_Device(d), 0023 m_LVList(lvPaths) 0024 { 0025 } 0026 0027 bool DeactivateLogicalVolumeJob::run(Report& parent) 0028 { 0029 bool rval = true; 0030 0031 Report* report = jobStarted(parent); 0032 0033 if (device().type() == Device::Type::LVM_Device) { 0034 for (const auto &p : device().partitionTable()->children()) { 0035 if (!p->roles().has(PartitionRole::Unallocated)) { 0036 if (!LvmDevice::deactivateLV(*report, *p)) { 0037 rval = false; 0038 } 0039 } 0040 } 0041 } 0042 0043 jobFinished(*report, rval); 0044 0045 return rval; 0046 } 0047 0048 QString DeactivateLogicalVolumeJob::description() const 0049 { 0050 return xi18nc("@info/plain", "Deactivate Logical Volumes: <filename>%1</filename>", device().prettyDeviceNodeList()); 0051 }