diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index 4bda317..91ca2be 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -198,7 +198,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl /** scan and contruct list of initialized LvmDevice objects. * - * @return list of initialized LvmDevice + * @return list of initialized LvmDevices */ QList LvmDevice::scanSystemLVM() { diff --git a/src/fs/luks.cpp b/src/fs/luks.cpp index d35aca2..819cbcc 100644 --- a/src/fs/luks.cpp +++ b/src/fs/luks.cpp @@ -329,6 +329,7 @@ void luks::loadInnerFileSystem(const QString& mapperNode) setUUID(m_innerFs->readUUID(mapperNode)); if (m_innerFs->supportGetUsed() == FileSystem::cmdSupportFileSystem) setSectorsUsed((m_innerFs->readUsedCapacity(mapperNode) + payloadOffset()) / m_logicalSectorSize ); + m_innerFs->scan(mapperNode); } void luks::createInnerFileSystem(FileSystem::Type type) diff --git a/src/fs/luks.h b/src/fs/luks.h index a45b3fa..5b35f30 100644 --- a/src/fs/luks.h +++ b/src/fs/luks.h @@ -158,6 +158,8 @@ public: void getKeySize(const QString& deviceNode); void getPayloadOffset(const QString& deviceNode); + FileSystem* innerFS() const { return m_innerFs; }; // avoid calling this unless necessary + QString mapperName() const { return m_MapperName; }; QString cipherName() const { return m_CipherName; }; QString cipherMode() const { return m_CipherMode; }; diff --git a/src/fs/lvm2_pv.cpp b/src/fs/lvm2_pv.cpp index 9648cc3..38ab206 100644 --- a/src/fs/lvm2_pv.cpp +++ b/src/fs/lvm2_pv.cpp @@ -66,6 +66,11 @@ void lvm2_pv::init() m_Copy = cmdSupportNone; // Copying PV can confuse LVM } +void lvm2_pv::scan(const QString& deviceNode) +{ + getPESize(deviceNode); +} + bool lvm2_pv::supportToolFound() const { return @@ -127,7 +132,7 @@ bool lvm2_pv::resize(Report& report, const QString& deviceNode, qint64 length) c qint64 lastPE = getTotalPE(deviceNode) - 1; // starts from 0 if (lastPE > 0) { // make sure that the PV is already in a VG - qint64 targetPE = (length - metadataOffset) / getPESize(deviceNode) - 1; // starts from 0 + qint64 targetPE = (length - metadataOffset) / peSize() - 1; // starts from 0 if (targetPE < lastPE) { //shrinking FS qint64 firstMovedPE = qMax(targetPE + 1, getAllocatedPE(deviceNode)); // starts from 1 ExternalCommand moveCmd(report, @@ -275,10 +280,10 @@ qint64 lvm2_pv::getPVSize(const QStringList& deviceNodeList) return sum; } -qint64 lvm2_pv::getPESize(const QString& deviceNode) const +void lvm2_pv::getPESize(const QString& deviceNode) { QString val = getpvField(QStringLiteral("vg_extent_size"), deviceNode); - return val.isEmpty() ? -1 : val.toLongLong(); + m_PESize = val.isEmpty() ? -1 : val.toLongLong(); } /** Get pvs command output with field name diff --git a/src/fs/lvm2_pv.h b/src/fs/lvm2_pv.h index 8aaaa44..c0f1df5 100644 --- a/src/fs/lvm2_pv.h +++ b/src/fs/lvm2_pv.h @@ -42,6 +42,7 @@ public: public: void init() override; + void scan(const QString& deviceNode) override; qint64 readUsedCapacity(const QString& deviceNode) const override; bool check(Report& report, const QString& deviceNode) const override; @@ -100,22 +101,22 @@ public: SupportTool supportToolName() const override; bool supportToolFound() const override; + static QString getpvField(const QString& fieldName, const QString& deviceNode = QString()); + static qint64 getTotalPE(const QString& deviceNode); static qint64 getTotalPE(const QStringList& deviceNodeList); static qint64 getFreePE(const QString& deviceNode); static qint64 getFreePE(const QStringList& deviceNodeList); static qint64 getAllocatedPE(const QString& deviceNode); static qint64 getAllocatedPE(const QStringList& deviceNodeList); - qint64 getPESize(const QString& deviceNode) const; // return PE size in bytes + void getPESize(const QString& deviceNode); // return PE size in bytes static qint64 getPVSize(const QString& deviceNode); // return PV size in bytes static qint64 getPVSize(const QStringList& deviceNodeList); - + static QString getVGName(const QString& deviceNode); + static QStringList getFreePV(); static bool isUsed(const QString& pvNode); - static QString getVGName(const QString& deviceNode); - static QString getpvField(const QString& fieldName, const QString& deviceNode = QString()); - - static QStringList getFreePV(); + qint64 peSize() const { return m_PESize; }; public: static CommandSupportType m_GetUsed; @@ -131,6 +132,9 @@ public: static CommandSupportType m_UpdateUUID; static CommandSupportType m_GetUUID; +private: + qint64 m_PESize; + }; }