Skip to content
Snippets Groups Projects
Commit 2d914248 authored by Aurélien Gâteau's avatar Aurélien Gâteau
Browse files

FillGlobalStorageJob: Add the partition UUID to global storage

parent 62d70654
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,7 @@ A list of dictionaries, one per partition. The dictionary contains the following
- `device`: path to the partition device
- `fs`: the name of the file system
- `mountPoint`: where the device should be mounted
- `uuid`: the UUID of the partition device
## rootMountPoint
......
......@@ -29,15 +29,37 @@
#include <core/partition.h>
#include <fs/filesystem.h>
// Qt
#include <QDebug>
#include <QDir>
#include <QFileInfo>
typedef QHash<QString, QString> UuidForPartitionHash;
static const char* UUID_DIR = "/dev/disk/by-uuid";
static UuidForPartitionHash
findPartitionUuids()
{
QDir dir( UUID_DIR );
UuidForPartitionHash hash;
for ( auto info : dir.entryInfoList( QDir::Files ) )
{
QString uuid = info.fileName();
QString path = info.canonicalFilePath();
hash.insert( path, uuid );
}
return hash;
}
static QVariant
mapForPartition( Partition* partition )
mapForPartition( Partition* partition, const QString& uuid )
{
QVariantMap map;
map[ "device" ] = partition->partitionPath();
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fs" ] = partition->fileSystem().name();
map[ "uuid" ] = uuid;
return map;
}
......@@ -68,10 +90,11 @@ FillGlobalStorageJob::exec()
QVariant
FillGlobalStorageJob::createPartitionList()
{
UuidForPartitionHash hash = findPartitionUuids();
QVariantList lst;
for( auto device : m_devices )
for( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it)
lst << mapForPartition( *it );
for ( auto device : m_devices )
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) );
return lst;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment