Avoiding segfault in DeleteOperation and ResizeOperation.

This commit is contained in:
Caio Carvalho 2018-05-07 22:56:24 -03:00
parent 1e95d01923
commit 6b0af70ccd
2 changed files with 24 additions and 18 deletions

View File

@ -128,13 +128,15 @@ bool DeleteOperation::canDelete(const Partition* p, const QList<Operation *> pen
}
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
// See if innerFS is LVM
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
FileSystem *fs = dynamic_cast<const FS::luks *>(&p->fileSystem())->innerFS();
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
if (dynamic_cast<CreateVolumeGroupOperation *>(op) && op->targets(*p))
return false;
if (fs) {
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
if (dynamic_cast<CreateVolumeGroupOperation *>(op) && op->targets(*p))
return false;
}
}
}
}

View File

@ -362,13 +362,15 @@ bool ResizeOperation::canShrink(const Partition* p, const QList<Operation *> pen
}
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
// See if innerFS is LVM
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
FileSystem *fs = dynamic_cast<const FS::luks *>(&p->fileSystem())->innerFS();
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
if (dynamic_cast<CreateVolumeGroupOperation *>(op) && op->targets(*p))
return false;
if (fs) {
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
if (dynamic_cast<CreateVolumeGroupOperation *>(op) && op->targets(*p))
return false;
}
}
}
}
@ -404,13 +406,15 @@ bool ResizeOperation::canMove(const Partition* p, const QList<Operation *> pendi
}
else if (p->fileSystem().type() == FileSystem::Type::Luks || p->fileSystem().type() == FileSystem::Type::Luks2) {
// See if innerFS is LVM
FileSystem *fs = static_cast<const FS::luks *>(&p->fileSystem())->innerFS();
FileSystem *fs = dynamic_cast<const FS::luks *>(&p->fileSystem())->innerFS();
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
if (dynamic_cast<CreateVolumeGroupOperation *>(op) && op->targets(*p))
return false;
if (fs) {
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
if (dynamic_cast<CreateVolumeGroupOperation *>(op) && op->targets(*p))
return false;
}
}
}
}