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,8 +128,9 @@ 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) {
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
@ -138,6 +139,7 @@ bool DeleteOperation::canDelete(const Partition* p, const QList<Operation *> pen
}
}
}
}
if (p->roles().has(PartitionRole::Unallocated))
return false;

View File

@ -362,8 +362,9 @@ 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) {
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
@ -372,6 +373,7 @@ bool ResizeOperation::canShrink(const Partition* p, const QList<Operation *> pen
}
}
}
}
// we can always grow, shrink or move a partition not yet written to disk
if (p->state() == Partition::State::New && !p->roles().has(PartitionRole::Luks))
@ -404,8 +406,9 @@ 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) {
if (fs->type() == FileSystem::Type::Lvm2_PV) {
// See if there is a newly created VG targeting this partition
for (Operation *op : qAsConst(pendingOps)) {
@ -414,6 +417,7 @@ bool ResizeOperation::canMove(const Partition* p, const QList<Operation *> pendi
}
}
}
}
// we can always grow, shrink or move a partition not yet written to disk
if (p->state() == Partition::State::New)