Move initLUKS from helpers to FS::luks.

This commit is contained in:
Chantara Tith 2016-09-12 23:49:20 +07:00
parent c70945b116
commit 874900fe72
6 changed files with 19 additions and 22 deletions

View File

@ -130,7 +130,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
// Handle LUKS partition
if (fs->type() == FileSystem::Luks) {
r |= PartitionRole::Luks;
initLuks(fs, this);
FS::luks::initLUKS(fs);
QString mapperNode = static_cast<FS::luks*>(fs)->mapperName();
mountPoint = FileSystem::detectMountPoint(fs, mapperNode);
mounted = FileSystem::detectMountStatus(fs, mapperNode);

View File

@ -21,8 +21,9 @@
#include "fs/filesystemfactory.h"
#include "util/capacity.h"
#include "util/externalcommand.h"
#include "util/capacity.h"
#include "util/helpers.h"
#include "util/report.h"
#include <QDebug>
@ -616,4 +617,18 @@ bool luks::canEncryptType(FileSystem::Type type)
}
}
void luks::initLUKS(FileSystem* fs)
{
if (fs->type() == FileSystem::Luks) {
FS::luks* luksFS = static_cast<FS::luks*>(fs);
QString mapperNode = luksFS->mapperName();
bool isCryptOpen = !mapperNode.isEmpty();
luksFS->setCryptOpen(isCryptOpen);
if (isCryptOpen) {
luksFS->loadInnerFileSystem(mapperNode);
luksFS->setMounted(::isMounted(mapperNode)); //isMounted from helpers.h
}
}
}
}

View File

@ -163,6 +163,7 @@ public:
qint64 payloadOffset() const { return m_PayloadOffset; };
static bool canEncryptType(FileSystem::Type type);
static void initLUKS(FileSystem* fs);
protected:
virtual QString readOuterUUID(const QString& deviceNode) const;

View File

@ -240,7 +240,7 @@ Device* LibPartedBackend::scanDevice(const QString& deviceNode)
// libparted does not handle LUKS partitions
if (fs->type() == FileSystem::Luks) {
r |= PartitionRole::Luks;
initLuks(fs, d);
FS::luks::initLUKS(fs);
QString mapperNode = static_cast<FS::luks*>(fs)->mapperName();
mountPoint = FileSystem::detectMountPoint(fs, mapperNode);
mounted = FileSystem::detectMountStatus(fs, mapperNode);

View File

@ -19,8 +19,6 @@
#include "util/helpers.h"
#include "util/externalcommand.h"
#include "util/globallog.h"
#include "fs/luks.h"
#include "core/device.h"
#include "ops/operation.h"
@ -86,21 +84,6 @@ bool isMounted(const QString& deviceNode)
return false;
}
void initLuks(FileSystem* fs, const Device* dev)
{
if (fs->type() == FileSystem::Luks) {
FS::luks* luksFS = static_cast<FS::luks*>(fs);
QString mapperNode = luksFS->mapperName();
bool isCryptOpen = !mapperNode.isEmpty();
luksFS->setCryptOpen(isCryptOpen);
luksFS->setLogicalSectorSize(dev->logicalSize());
if (isCryptOpen) {
luksFS->loadInnerFileSystem(mapperNode);
}
luksFS->setMounted(isMounted(mapperNode));
}
}
KAboutData aboutKPMcore()
{
KAboutData aboutData( QStringLiteral("kpmcore"),

View File

@ -39,8 +39,6 @@ LIBKPMCORE_EXPORT bool checkAccessibleDevices();
LIBKPMCORE_EXPORT bool isMounted(const QString& deviceNode);
LIBKPMCORE_EXPORT void initLuks(FileSystem* fs, const Device* dev);
LIBKPMCORE_EXPORT KAboutData aboutKPMcore();
#endif