2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2014-06-30 15:03:29 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014 Aurélien Gâteau <agateau@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2015-2016 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2014-06-30 15:03:29 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2014-06-30 15:03:29 +02:00
|
|
|
*
|
|
|
|
*/
|
2015-09-18 15:41:07 +02:00
|
|
|
#ifndef KPMHELPERS_H
|
|
|
|
#define KPMHELPERS_H
|
2014-06-30 15:03:29 +02:00
|
|
|
|
2015-07-02 13:49:21 +02:00
|
|
|
// KPMcore
|
2016-03-04 19:11:31 +01:00
|
|
|
#include <kpmcore/core/partitiontable.h>
|
2015-07-02 13:49:21 +02:00
|
|
|
#include <kpmcore/fs/filesystem.h>
|
2014-08-04 18:16:05 +02:00
|
|
|
|
2014-07-23 18:14:27 +02:00
|
|
|
// Qt
|
|
|
|
#include <QList>
|
|
|
|
|
2015-05-22 18:14:53 +02:00
|
|
|
#include <functional>
|
|
|
|
|
2014-07-23 18:14:27 +02:00
|
|
|
class Device;
|
2014-06-30 15:03:29 +02:00
|
|
|
class Partition;
|
2014-08-04 18:16:05 +02:00
|
|
|
class PartitionNode;
|
|
|
|
class PartitionRole;
|
2014-06-30 15:03:29 +02:00
|
|
|
|
2019-06-13 14:10:49 +02:00
|
|
|
#if defined( WITH_KPMCORE4API )
|
2020-02-14 11:15:57 +01:00
|
|
|
#define KPM_PARTITION_FLAG( x ) PartitionTable::Flag::x
|
|
|
|
#define KPM_PARTITION_STATE( x ) Partition::State::x
|
2019-03-20 16:37:50 +01:00
|
|
|
#define KPM_PARTITION_FLAG_ESP PartitionTable::Flag::Boot
|
2019-03-20 16:32:13 +01:00
|
|
|
#else
|
2020-02-14 11:15:57 +01:00
|
|
|
#define KPM_PARTITION_FLAG( x ) PartitionTable::Flag##x
|
|
|
|
#define KPM_PARTITION_STATE( x ) Partition::State##x
|
2019-03-20 16:37:50 +01:00
|
|
|
#define KPM_PARTITION_FLAG_ESP PartitionTable::FlagEsp
|
2019-03-20 16:32:13 +01:00
|
|
|
#endif
|
|
|
|
|
2014-08-08 11:46:43 +02:00
|
|
|
/**
|
|
|
|
* Helper functions to manipulate partitions
|
|
|
|
*/
|
2015-09-18 15:41:07 +02:00
|
|
|
namespace KPMHelpers
|
2014-06-30 15:03:29 +02:00
|
|
|
{
|
|
|
|
|
2014-08-08 11:46:43 +02:00
|
|
|
/**
|
|
|
|
* Iterates on all devices and return the first partition which is associated
|
|
|
|
* with mountPoint. This uses PartitionInfo::mountPoint(), not Partition::mountPoint()
|
|
|
|
*/
|
2014-07-23 18:14:27 +02:00
|
|
|
Partition* findPartitionByMountPoint( const QList< Device* >& devices, const QString& mountPoint );
|
|
|
|
|
2014-08-08 11:46:43 +02:00
|
|
|
/**
|
|
|
|
* Helper function to create a new Partition object (does not create anything
|
|
|
|
* on the disk) associated with a FileSystem.
|
|
|
|
*/
|
2016-03-04 19:11:31 +01:00
|
|
|
Partition* createNewPartition( PartitionNode* parent,
|
|
|
|
const Device& device,
|
|
|
|
const PartitionRole& role,
|
|
|
|
FileSystem::Type fsType,
|
|
|
|
qint64 firstSector,
|
|
|
|
qint64 lastSector,
|
2018-11-11 13:55:46 +01:00
|
|
|
PartitionTable::Flags flags );
|
2014-08-04 18:16:05 +02:00
|
|
|
|
2016-04-22 16:01:31 +02:00
|
|
|
Partition* createNewEncryptedPartition( PartitionNode* parent,
|
|
|
|
const Device& device,
|
|
|
|
const PartitionRole& role,
|
|
|
|
FileSystem::Type fsType,
|
|
|
|
qint64 firstSector,
|
|
|
|
qint64 lastSector,
|
|
|
|
const QString& passphrase,
|
2018-11-11 13:55:46 +01:00
|
|
|
PartitionTable::Flags flags );
|
2016-04-22 16:01:31 +02:00
|
|
|
|
2014-08-07 12:59:24 +02:00
|
|
|
Partition* clonePartition( Device* device, Partition* partition );
|
2015-12-16 15:46:32 +01:00
|
|
|
|
2020-02-14 11:15:57 +01:00
|
|
|
} // namespace KPMHelpers
|
2014-06-30 15:03:29 +02:00
|
|
|
|
2015-09-18 15:41:07 +02:00
|
|
|
#endif /* KPMHELPERS_H */
|