Do not set LUKS logical sector size to 512.
This breaks used space reporting for LUKS encrypted LVM LV.
This commit is contained in:
parent
f34b13f545
commit
901d01185f
|
@ -132,7 +132,7 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
|
||||||
if (fs->type() == FileSystem::Luks) {
|
if (fs->type() == FileSystem::Luks) {
|
||||||
r |= PartitionRole::Luks;
|
r |= PartitionRole::Luks;
|
||||||
FS::luks* luksFs = static_cast<FS::luks*>(fs);
|
FS::luks* luksFs = static_cast<FS::luks*>(fs);
|
||||||
luksFs->initLUKS();
|
luksFs->initLUKS(logicalSize());
|
||||||
|
|
||||||
QString mapperNode = luksFs->mapperName();
|
QString mapperNode = luksFs->mapperName();
|
||||||
mountPoint = FileSystem::detectMountPoint(fs, mapperNode);
|
mountPoint = FileSystem::detectMountPoint(fs, mapperNode);
|
||||||
|
|
|
@ -62,6 +62,7 @@ luks::luks(qint64 firstsector,
|
||||||
, m_isCryptOpen(false)
|
, m_isCryptOpen(false)
|
||||||
, m_cryptsetupFound(m_Create != cmdSupportNone)
|
, m_cryptsetupFound(m_Create != cmdSupportNone)
|
||||||
, m_isMounted(false)
|
, m_isMounted(false)
|
||||||
|
, m_logicalSectorSize(512)
|
||||||
, m_KeySize(-1)
|
, m_KeySize(-1)
|
||||||
, m_PayloadOffset(-1)
|
, m_PayloadOffset(-1)
|
||||||
{
|
{
|
||||||
|
@ -495,7 +496,7 @@ bool luks::resize(Report& report, const QString& deviceNode, qint64 newLength) c
|
||||||
else if (m_innerFs->resize(report, mapperName(), payloadLength))
|
else if (m_innerFs->resize(report, mapperName(), payloadLength))
|
||||||
{
|
{
|
||||||
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"),
|
ExternalCommand cryptResizeCmd(report, QStringLiteral("cryptsetup"),
|
||||||
{ QStringLiteral("--size"), QString::number(payloadLength / m_logicalSectorSize), // LUKS assumes 512 bytes sector
|
{ QStringLiteral("--size"), QString::number(payloadLength / 512), // LUKS payload length is specified in multiples of 512 bytes
|
||||||
QStringLiteral("resize"), mapperName() });
|
QStringLiteral("resize"), mapperName() });
|
||||||
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
report.line() << xi18nc("@info:progress", "Resizing LUKS crypt on partition <filename>%1</filename>.", deviceNode);
|
||||||
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
|
if (cryptResizeCmd.run(-1) && cryptResizeCmd.exitCode() == 0)
|
||||||
|
@ -650,8 +651,9 @@ bool luks::canEncryptType(FileSystem::Type type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void luks::initLUKS()
|
void luks::initLUKS(unsigned int sectorSize)
|
||||||
{
|
{
|
||||||
|
setLogicalSectorSize(sectorSize);
|
||||||
QString mapperNode = mapperName();
|
QString mapperNode = mapperName();
|
||||||
bool isCryptOpen = !mapperNode.isEmpty();
|
bool isCryptOpen = !mapperNode.isEmpty();
|
||||||
setCryptOpen(isCryptOpen);
|
setCryptOpen(isCryptOpen);
|
||||||
|
|
|
@ -126,6 +126,10 @@ public:
|
||||||
return m_GetUUID;
|
return m_GetUUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setLogicalSectorSize(unsigned int logicalSectorSize) {
|
||||||
|
m_logicalSectorSize = logicalSectorSize;
|
||||||
|
}
|
||||||
|
|
||||||
bool check(Report& report, const QString& deviceNode) const override;
|
bool check(Report& report, const QString& deviceNode) const override;
|
||||||
bool create(Report& report, const QString& deviceNode) override;
|
bool create(Report& report, const QString& deviceNode) override;
|
||||||
SupportTool supportToolName() const override;
|
SupportTool supportToolName() const override;
|
||||||
|
@ -182,7 +186,7 @@ public:
|
||||||
qint64 payloadOffset() const { return m_PayloadOffset; }
|
qint64 payloadOffset() const { return m_PayloadOffset; }
|
||||||
|
|
||||||
static bool canEncryptType(FileSystem::Type type);
|
static bool canEncryptType(FileSystem::Type type);
|
||||||
void initLUKS();
|
void initLUKS(unsigned int sectorSize);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual QString readOuterUUID(const QString& deviceNode) const;
|
virtual QString readOuterUUID(const QString& deviceNode) const;
|
||||||
|
@ -208,7 +212,7 @@ private:
|
||||||
mutable bool m_cryptsetupFound;
|
mutable bool m_cryptsetupFound;
|
||||||
QString m_passphrase;
|
QString m_passphrase;
|
||||||
bool m_isMounted;
|
bool m_isMounted;
|
||||||
constexpr static unsigned int m_logicalSectorSize = 512;
|
unsigned int m_logicalSectorSize;
|
||||||
|
|
||||||
QString m_MapperName;
|
QString m_MapperName;
|
||||||
QString m_CipherName;
|
QString m_CipherName;
|
||||||
|
|
|
@ -341,7 +341,7 @@ void LibPartedBackend::scanDevicePartitions(Device& d, PedDisk* pedDisk)
|
||||||
if (fs->type() == FileSystem::Luks) {
|
if (fs->type() == FileSystem::Luks) {
|
||||||
r |= PartitionRole::Luks;
|
r |= PartitionRole::Luks;
|
||||||
FS::luks* luksFs = static_cast<FS::luks*>(fs);
|
FS::luks* luksFs = static_cast<FS::luks*>(fs);
|
||||||
luksFs->initLUKS();
|
luksFs->initLUKS(d.logicalSize());
|
||||||
QString mapperNode = luksFs->mapperName();
|
QString mapperNode = luksFs->mapperName();
|
||||||
mountPoint = FileSystem::detectMountPoint(fs, mapperNode);
|
mountPoint = FileSystem::detectMountPoint(fs, mapperNode);
|
||||||
mounted = FileSystem::detectMountStatus(fs, mapperNode);
|
mounted = FileSystem::detectMountStatus(fs, mapperNode);
|
||||||
|
|
Loading…
Reference in New Issue