Disallow partition delete operation if the FS is cryptOpen.

This commit is contained in:
Teo Mrnjavac 2016-04-26 11:50:44 +02:00
parent 12c03cfeff
commit 7ff137233a
1 changed files with 12 additions and 0 deletions

View File

@ -21,6 +21,7 @@
#include "core/partition.h"
#include "core/device.h"
#include "core/partitiontable.h"
#include "fs/luks.h"
#include "jobs/deletepartitionjob.h"
#include "jobs/deletefilesystemjob.h"
@ -123,5 +124,16 @@ bool DeleteOperation::canDelete(const Partition* p)
if (p->roles().has(PartitionRole::Extended))
return p->children().size() == 1 && p->children()[0]->roles().has(PartitionRole::Unallocated);
if (p->roles().has(PartitionRole::Luks))
{
const FileSystem& fsRef = p->fileSystem();
const FS::luks* luksFs = dynamic_cast<const FS::luks*>(&fsRef);
if (!luksFs)
return false;
if (luksFs->isCryptOpen() || luksFs->isMounted())
return false;
}
return true;
}