LVM support #6
|
@ -241,3 +241,18 @@ qint32 LvmDevice::getTotalLE(const QString& lvpath)
|
|||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool LvmDevice::removeLV(Device& dev, Partition& part)
|
||||
{
|
||||
ExternalCommand cmd(QStringLiteral("lvm"),
|
||||
{ QStringLiteral("lvremove"),
|
||||
QStringLiteral("--yes"),
|
||||
part.partitionPath()});
|
||||
|
||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||
//TODO: remove Partition from PartitionTable and delete from memory
|
||||
dev.partitionTable()->remove(&part);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
|
||||
static qint32 getTotalLE(const QString& lvpath);
|
||||
|
||||
static bool removeLV(Device& dev, Partition& part);
|
||||
|
||||
protected:
|
||||
void initPartitions();
|
||||
QList<QString> deviceNodeList() const override;
|
||||
|
|
|
@ -63,8 +63,12 @@ bool DeleteFileSystemJob::run(Report& parent)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (partition().roles().has(PartitionRole::Extended))
|
||||
if (partition().roles().has(PartitionRole::Extended)) {
|
||||
rval = true;
|
||||
} else if (device().type() == Device::LVM_Device) {
|
||||
//TODO: LVM delete Filesystem Job. libparted can't help us here.
|
||||
rval = true;
|
||||
}
|
||||
else {
|
||||
if (!partition().fileSystem().remove(*report, partition().deviceNode())) {
|
||||
jobFinished(*report, rval);
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include "core/partition.h"
|
||||
#include "core/device.h"
|
||||
#include "core/lvmdevice.h"
|
||||
|
||||
#include "util/report.h"
|
||||
|
||||
|
@ -56,27 +57,31 @@ bool DeletePartitionJob::run(Report& parent)
|
|||
|
||||
Report* report = jobStarted(parent);
|
||||
|
||||
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
|
||||
if (device().type() == Device::Disk_Device) {
|
||||
CoreBackendDevice* backendDevice = CoreBackendManager::self()->backend()->openDevice(device().deviceNode());
|
||||
|
||||
if (backendDevice) {
|
||||
CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();
|
||||
if (backendDevice) {
|
||||
CoreBackendPartitionTable* backendPartitionTable = backendDevice->openPartitionTable();
|
||||
|
||||
if (backendPartitionTable) {
|
||||
rval = backendPartitionTable->deletePartition(*report, partition());
|
||||
if (backendPartitionTable) {
|
||||
rval = backendPartitionTable->deletePartition(*report, partition());
|
||||
|
||||
if (!rval)
|
||||
report->line() << xi18nc("@info:progress", "Could not delete partition <filename>%1</filename>.", partition().deviceNode());
|
||||
else
|
||||
backendPartitionTable->commit();
|
||||
if (!rval)
|
||||
report->line() << xi18nc("@info:progress", "Could not delete partition <filename>%1</filename>.", partition().deviceNode());
|
||||
else
|
||||
backendPartitionTable->commit();
|
||||
|
||||
delete backendPartitionTable;
|
||||
delete backendPartitionTable;
|
||||
|
||||
} else
|
||||
report->line() << xi18nc("@info:progress", "Could not open partition table on device <filename>%1</filename> to delete partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
|
||||
|
||||
delete backendDevice;
|
||||
} else
|
||||
report->line() << xi18nc("@info:progress", "Could not open partition table on device <filename>%1</filename> to delete partition <filename>%2</filename>.", device().deviceNode(), partition().deviceNode());
|
||||
|
||||
delete backendDevice;
|
||||
} else
|
||||
report->line() << xi18nc("@info:progress", "Deleting partition failed: Could not open device <filename>%1</filename>.", device().deviceNode());
|
||||
report->line() << xi18nc("@info:progress", "Deleting partition failed: Could not open device <filename>%1</filename>.", device().deviceNode());
|
||||
} else if (device().type() == Device::LVM_Device) {
|
||||
rval = LvmDevice::removeLV(device(), partition());
|
||||
}
|
||||
|
||||
jobFinished(*report, rval);
|
||||
|
||||
|
|
Loading…
Reference in New Issue