From 95a74c63d13d6580688cdde2709f975858747d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrius=20=C5=A0tikonas?= Date: Thu, 14 Sep 2017 17:50:21 +0100 Subject: [PATCH] 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. --- src/fs/filesystem.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fs/filesystem.cpp b/src/fs/filesystem.cpp index 3c484bf..8c8436a 100644 --- a/src/fs/filesystem.cpp +++ b/src/fs/filesystem.cpp @@ -33,6 +33,7 @@ #include +#include #include #include @@ -130,12 +131,16 @@ QString FileSystem::detectMountPoint(FileSystem* fs, const QString& partitionPat if (fs->type() == FileSystem::Lvm2_PV) return FS::lvm2_pv::getVGName(partitionPath); + if (partitionPath.isEmpty()) // Happens when during initial scan LUKS is closed + return QString(); + QStringList mountPoints; - QFileInfo kernelPath(partitionPath); + QFileInfo partitionPathFileInfo(partitionPath); const QList mountedVolumes = QStorageInfo::mountedVolumes(); for (const QStorageInfo &storage : mountedVolumes) { - QFileInfo kernelPath2(QString::fromUtf8(storage.device())); - if (kernelPath2.canonicalFilePath() == kernelPath.canonicalFilePath() ) { + QFileInfo deviceFileInfo(QString::fromUtf8(storage.device())); + qDebug() << storage.device() << storage.rootPath(); + if (partitionPathFileInfo.canonicalFilePath() == deviceFileInfo.canonicalFilePath() ) { mountPoints.append(storage.rootPath()); } }