FS: use untranslated name to identify filesystem

Resolves issue where 'linuxswap' is translated to 'Linux-Swap',
for instance. FileSystem::name() provides a translated name,
not an untranslated one.

This should move to KPMCore.

FIXES #797
main
Adriaan de Groot 7 years ago
parent 8b61b3ddc3
commit 9f1cca5ec7

@ -76,6 +76,50 @@ getLuksUuid( const QString& path )
return uuid;
}
// TODO: this will be available from KPMCore soon
static const char* filesystem_labels[] = {
"unknown",
"extended",
"ext2",
"ext3",
"ext4",
"linuxswap",
"fat16",
"fat32",
"ntfs",
"reiser",
"reiser4",
"xfs",
"jfs",
"hfs",
"hfsplus",
"ufs",
"unformatted",
"btrfs",
"hpfs",
"luks",
"ocfs2",
"zfs",
"exfat",
"nilfs2",
"lvm2 pv",
"f2fs",
"udf",
"iso9660",
};
Q_STATIC_ASSERT_X((sizeof(filesystem_labels) / sizeof(char *)) >= FileSystem::__lastType, "Mismatch in filesystem labels");
static QString
untranslatedTypeName(FileSystem::Type t)
{
Q_ASSERT( t >= 0 );
Q_ASSERT( t <= FileSystem::__lastType );
return QLatin1String(filesystem_labels[t]);
}
static QVariant
mapForPartition( Partition* partition, const QString& uuid )
@ -83,14 +127,15 @@ mapForPartition( Partition* partition, const QString& uuid )
QVariantMap map;
map[ "device" ] = partition->partitionPath();
map[ "mountPoint" ] = PartitionInfo::mountPoint( partition );
map[ "fs" ] = partition->fileSystem().name();
map[ "fsName" ] = partition->fileSystem().name();
map[ "fs" ] = untranslatedTypeName( partition->fileSystem().type() );
if ( partition->fileSystem().type() == FileSystem::Luks &&
dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS() )
map[ "fs" ] = dynamic_cast< FS::luks& >( partition->fileSystem() ).innerFS()->name();
map[ "uuid" ] = uuid;
cDebug() << partition->partitionPath()
<< "mtpoint:" << PartitionInfo::mountPoint( partition )
<< "fs:" << map[ "fs" ]
<< "fs:" << map[ "fs" ] << '(' << map[ "fsName" ] << ')'
<< uuid;
if ( partition->roles().has( PartitionRole::Luks ) )

Loading…
Cancel
Save