[partition] Introduce helpers for Cala Luks generation to KPM generations

This commit is contained in:
Adriaan de Groot 2022-11-05 16:28:54 +01:00
parent 703cbb7bf3
commit 5ef1af5aef
2 changed files with 30 additions and 0 deletions

View File

@ -299,6 +299,24 @@ cryptVersion( Partition* partition )
return luksVersion; return luksVersion;
} }
FileSystem::Type
luksGenerationToFSName( Config::LuksGeneration luksGeneration )
{
// Convert luksGenerationChoice from partition.conf into its
// corresponding file system type from KPMCore.
switch ( luksGeneration )
{
case Config::LuksGeneration::Luks2:
return FileSystem::Type::Luks2;
case Config::LuksGeneration::Luks1:
return FileSystem::Type::Luks;
default:
cWarning() << "luksGeneration not supported, defaulting to \"luks\"";
return FileSystem::Type::Luks;
}
}
Calamares::JobResult Calamares::JobResult
execute( Operation& operation, const QString& failureMessage ) execute( Operation& operation, const QString& failureMessage )
{ {

View File

@ -11,6 +11,7 @@
#ifndef KPMHELPERS_H #ifndef KPMHELPERS_H
#define KPMHELPERS_H #define KPMHELPERS_H
#include "Config.h"
#include "Job.h" #include "Job.h"
#include <kpmcore/core/partitiontable.h> #include <kpmcore/core/partitiontable.h>
@ -120,6 +121,17 @@ bool cryptLabel( Partition* partition, const QString& label );
*/ */
int cryptVersion( Partition* partition ); int cryptVersion( Partition* partition );
/** @brief Convert a luksGeneration into its FS type for KPMCore.
*
* Will convert Luks1 into FileSystem::Type::luks and Luks2 into
* FileSystem::Type::luks2 for KPMCore partitioning functions.
*
* @return The LUKS FS type (default @c luks )
*/
FileSystem::Type
luksGenerationToFSName( Config::LuksGeneration luksGeneration );
/** @brief Return a result for an @p operation /** @brief Return a result for an @p operation
* *
* Executes the operation, and if successful, returns a success result. * Executes the operation, and if successful, returns a success result.