Add a template to easily access inner filesystem inside LUKS.
This commit is contained in:
parent
23bf7585ed
commit
07ed3d97cf
|
@ -18,12 +18,11 @@
|
|||
#include "ops/resizevolumegroupoperation.h"
|
||||
|
||||
#include "core/lvmdevice.h"
|
||||
#include "fs/lvm2_pv.h"
|
||||
#include "fs/luks.h"
|
||||
#include "core/partition.h"
|
||||
|
||||
#include "fs/lvm2_pv.h"
|
||||
#include "jobs/resizevolumegroupjob.h"
|
||||
#include "jobs/movephysicalvolumejob.h"
|
||||
#include "util/helpers.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
@ -61,24 +60,21 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QList
|
|||
|
||||
qint64 currentFreePE = 0;
|
||||
for (const auto &p : currentList()) {
|
||||
const FS::lvm2_pv* lvm2PVFs = p->roles().has(PartitionRole::Luks) ?
|
||||
static_cast<const FS::lvm2_pv*>(static_cast<const FS::luks*>(&p->fileSystem())->innerFS()) : // LVM inside LUKS partition
|
||||
static_cast<const FS::lvm2_pv*>(&p->fileSystem()); // simple LVM
|
||||
FS::lvm2_pv *lvm2PVFs;
|
||||
innerFS(p, lvm2PVFs);
|
||||
currentFreePE += lvm2PVFs->freePE();
|
||||
}
|
||||
qint64 removedFreePE = 0;
|
||||
for (const auto &p : toRemoveList) { // FIXME: qAsConst
|
||||
const FS::lvm2_pv* lvm2PVFs = p->roles().has(PartitionRole::Luks) ?
|
||||
static_cast<const FS::lvm2_pv*>(static_cast<const FS::luks*>(&p->fileSystem())->innerFS()) : // LVM inside LUKS partition
|
||||
static_cast<const FS::lvm2_pv*>(&p->fileSystem()); // simple LVM
|
||||
FS::lvm2_pv *lvm2PVFs;
|
||||
innerFS(p, lvm2PVFs);
|
||||
removedFreePE += lvm2PVFs->freePE();
|
||||
}
|
||||
qint64 freePE = currentFreePE - removedFreePE;
|
||||
qint64 movePE = 0;
|
||||
for (const auto &p : toRemoveList) { // FIXME: qAsConst
|
||||
const FS::lvm2_pv* lvm2PVFs = p->roles().has(PartitionRole::Luks) ?
|
||||
static_cast<const FS::lvm2_pv*>(static_cast<const FS::luks*>(&p->fileSystem())->innerFS()) : // LVM inside LUKS partition
|
||||
static_cast<const FS::lvm2_pv*>(&p->fileSystem()); // simple LVM
|
||||
FS::lvm2_pv *lvm2PVFs;
|
||||
innerFS(p, lvm2PVFs);
|
||||
movePE += lvm2PVFs->allocatedPE();
|
||||
}
|
||||
qint64 growPE = 0;
|
||||
|
|
|
@ -19,12 +19,15 @@
|
|||
|
||||
#define HELPERS__H
|
||||
|
||||
#include "core/partition.h"
|
||||
#include "fs/filesystem.h"
|
||||
#include "fs/luks.h"
|
||||
|
||||
#include "util/libpartitionmanagerexport.h"
|
||||
|
||||
class KAboutData;
|
||||
|
||||
class Partition;
|
||||
class QString;
|
||||
class QPoint;
|
||||
class QTreeWidget;
|
||||
|
@ -41,4 +44,18 @@ LIBKPMCORE_EXPORT bool isMounted(const QString& deviceNode);
|
|||
|
||||
LIBKPMCORE_EXPORT KAboutData aboutKPMcore();
|
||||
|
||||
/** Pointer to the file system (which might be inside LUKS container) contained in the partition
|
||||
* @param p Partition where we look for file system
|
||||
* @return pointer to the FileSystem
|
||||
*/
|
||||
template <typename T>
|
||||
inline LIBKPMCORE_EXPORT void innerFS (const Partition* p, T& fs)
|
||||
{
|
||||
Partition* partition = const_cast<Partition*>(p);
|
||||
if (p->roles().has(PartitionRole::Luks))
|
||||
fs = dynamic_cast<const T>(dynamic_cast<const FS::luks* const>(&p->fileSystem())->innerFS());
|
||||
else
|
||||
fs = dynamic_cast<const T>(&partition->fileSystem());
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue