From cd304b7a6f88fd0e97519fa8ecaf8cee64c535c7 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Thu, 5 May 2016 13:29:08 +0200 Subject: [PATCH] Get luksUuid instead of innerFs UUID. --- .../partition/jobs/FillGlobalStorageJob.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/modules/partition/jobs/FillGlobalStorageJob.cpp b/src/modules/partition/jobs/FillGlobalStorageJob.cpp index 1c802eb75..469abe441 100644 --- a/src/modules/partition/jobs/FillGlobalStorageJob.cpp +++ b/src/modules/partition/jobs/FillGlobalStorageJob.cpp @@ -37,6 +37,7 @@ #include #include #include +#include typedef QHash UuidForPartitionHash; @@ -62,6 +63,22 @@ findPartitionUuids( QList < Device* > devices ) return hash; } + +static QString +getLuksUuid( const QString& path ) +{ + QProcess process; + process.setProgram( "cryptsetup" ); + process.setArguments( { "luksUUID", path } ); + process.start(); + process.waitForFinished(); + if ( process.exitStatus() != QProcess::NormalExit || process.exitCode() ) + return QString(); + QString uuid = QString::fromLocal8Bit( process.readAllStandardOutput() ).trimmed(); + return uuid; +} + + static QVariant mapForPartition( Partition* partition, const QString& uuid ) { @@ -82,6 +99,7 @@ mapForPartition( Partition* partition, const QString& uuid ) if ( luksFs ) { map[ "luksMapperName" ] = luksFs->suggestedMapperName( partition->partitionPath() ); + map[ "luksUuid" ] = getLuksUuid( partition->partitionPath() ); cDebug() << "luksMapperName:" << map[ "luksMapperName" ]; } }