Do not report wrong mountpoint for closed LUKS file systems.

When libparted scans luks partitions it calls detectFileSystem
regardless of whether luks is open or closed. This results in
mapperNode being empty, so we need to prevent detectFileSystem
from reporting anything in this case.
This commit is contained in:
Andrius Štikonas 2017-09-14 17:50:21 +01:00
parent f29534e7c7
commit 95a74c63d1
1 changed files with 8 additions and 3 deletions

View File

@ -33,6 +33,7 @@
#include <KLocalizedString> #include <KLocalizedString>
#include <QDebug>
#include <QFileInfo> #include <QFileInfo>
#include <QStorageInfo> #include <QStorageInfo>
@ -130,12 +131,16 @@ QString FileSystem::detectMountPoint(FileSystem* fs, const QString& partitionPat
if (fs->type() == FileSystem::Lvm2_PV) if (fs->type() == FileSystem::Lvm2_PV)
return FS::lvm2_pv::getVGName(partitionPath); return FS::lvm2_pv::getVGName(partitionPath);
if (partitionPath.isEmpty()) // Happens when during initial scan LUKS is closed
return QString();
QStringList mountPoints; QStringList mountPoints;
QFileInfo kernelPath(partitionPath); QFileInfo partitionPathFileInfo(partitionPath);
const QList<QStorageInfo> mountedVolumes = QStorageInfo::mountedVolumes(); const QList<QStorageInfo> mountedVolumes = QStorageInfo::mountedVolumes();
for (const QStorageInfo &storage : mountedVolumes) { for (const QStorageInfo &storage : mountedVolumes) {
QFileInfo kernelPath2(QString::fromUtf8(storage.device())); QFileInfo deviceFileInfo(QString::fromUtf8(storage.device()));
if (kernelPath2.canonicalFilePath() == kernelPath.canonicalFilePath() ) { qDebug() << storage.device() << storage.rootPath();
if (partitionPathFileInfo.canonicalFilePath() == deviceFileInfo.canonicalFilePath() ) {
mountPoints.append(storage.rootPath()); mountPoints.append(storage.rootPath());
} }
} }