FillGlobalStorageJob: Add the partition UUID to global storage
This commit is contained in:
parent
62d706543b
commit
2d9142487b
@ -17,6 +17,7 @@ A list of dictionaries, one per partition. The dictionary contains the following
|
|||||||
- `device`: path to the partition device
|
- `device`: path to the partition device
|
||||||
- `fs`: the name of the file system
|
- `fs`: the name of the file system
|
||||||
- `mountPoint`: where the device should be mounted
|
- `mountPoint`: where the device should be mounted
|
||||||
|
- `uuid`: the UUID of the partition device
|
||||||
|
|
||||||
## rootMountPoint
|
## rootMountPoint
|
||||||
|
|
||||||
|
@ -29,15 +29,37 @@
|
|||||||
#include <core/partition.h>
|
#include <core/partition.h>
|
||||||
#include <fs/filesystem.h>
|
#include <fs/filesystem.h>
|
||||||
|
|
||||||
|
// Qt
|
||||||
#include <QDebug>
|
#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
|
static QVariant
|
||||||
mapForPartition( Partition* partition )
|
mapForPartition( Partition* partition, const QString& uuid )
|
||||||
{
|
{
|
||||||
QVariantMap map;
|
QVariantMap map;
|
||||||
map[ "device" ] = partition->partitionPath();
|
map[ "device" ] = partition->partitionPath();
|
||||||
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
|
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
|
||||||
map[ "fs" ] = partition->fileSystem().name();
|
map[ "fs" ] = partition->fileSystem().name();
|
||||||
|
map[ "uuid" ] = uuid;
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,10 +90,11 @@ FillGlobalStorageJob::exec()
|
|||||||
QVariant
|
QVariant
|
||||||
FillGlobalStorageJob::createPartitionList()
|
FillGlobalStorageJob::createPartitionList()
|
||||||
{
|
{
|
||||||
|
UuidForPartitionHash hash = findPartitionUuids();
|
||||||
QVariantList lst;
|
QVariantList lst;
|
||||||
for( auto device : m_devices )
|
for ( auto device : m_devices )
|
||||||
for( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it)
|
for ( auto it = PartitionIterator::begin( device ); it != PartitionIterator::end( device ); ++it )
|
||||||
lst << mapForPartition( *it );
|
lst << mapForPartition( *it, hash.value( ( *it )->partitionPath() ) );
|
||||||
return lst;
|
return lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user