2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2019-01-07 17:25:22 +01:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2018-2019 Collabora Ltd <arnaud.ferraris@collabora.com>
|
|
|
|
* SPDX-FileCopyrightText: 2019 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2019-01-07 17:25:22 +01:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2019-01-07 17:25:22 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARTITIONLAYOUT_H
|
|
|
|
#define PARTITIONLAYOUT_H
|
|
|
|
|
2019-05-08 19:26:31 +02:00
|
|
|
#include "partition/PartitionSize.h"
|
|
|
|
|
2019-02-28 13:18:02 +01:00
|
|
|
#include "core/PartUtils.h"
|
|
|
|
|
2019-01-07 17:25:22 +01:00
|
|
|
// KPMcore
|
|
|
|
#include <kpmcore/core/partitiontable.h>
|
2019-02-22 18:42:16 +01:00
|
|
|
#include <kpmcore/fs/filesystem.h>
|
2019-01-07 17:25:22 +01:00
|
|
|
|
|
|
|
// Qt
|
|
|
|
#include <QList>
|
|
|
|
#include <QObject>
|
2020-03-16 22:25:55 +01:00
|
|
|
#include <QVariantMap>
|
2019-01-07 17:25:22 +01:00
|
|
|
|
|
|
|
class Partition;
|
|
|
|
|
|
|
|
class PartitionLayout
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct PartitionEntry
|
|
|
|
{
|
|
|
|
QString partLabel;
|
2020-05-14 18:30:58 +02:00
|
|
|
QString partUUID;
|
2020-03-19 13:37:21 +01:00
|
|
|
QString partType;
|
2020-11-02 15:40:32 +01:00
|
|
|
quint64 partAttributes = 0;
|
2019-01-07 17:25:22 +01:00
|
|
|
QString partMountPoint;
|
2019-02-22 18:42:16 +01:00
|
|
|
FileSystem::Type partFileSystem = FileSystem::Unknown;
|
2020-03-16 22:25:55 +01:00
|
|
|
QVariantMap partFeatures;
|
2019-05-14 11:52:58 +02:00
|
|
|
CalamaresUtils::Partition::PartitionSize partSize;
|
|
|
|
CalamaresUtils::Partition::PartitionSize partMinSize;
|
|
|
|
CalamaresUtils::Partition::PartitionSize partMaxSize;
|
2019-02-11 23:37:14 +01:00
|
|
|
|
|
|
|
/// @brief All-zeroes PartitionEntry
|
2020-06-21 02:30:22 +02:00
|
|
|
PartitionEntry();
|
2020-11-02 16:01:10 +01:00
|
|
|
/** @brief Parse @p mountPoint, @p size, @p minSize and @p maxSize to their respective member variables
|
|
|
|
*
|
|
|
|
* Sets a specific FS type (not parsed from string like the other
|
|
|
|
* constructor).
|
|
|
|
*/
|
2020-11-02 22:32:44 +01:00
|
|
|
PartitionEntry( FileSystem::Type fs,
|
2020-11-02 16:01:10 +01:00
|
|
|
const QString& mountPoint,
|
2020-06-22 00:02:04 +02:00
|
|
|
const QString& size,
|
|
|
|
const QString& minSize = QString(),
|
|
|
|
const QString& maxSize = QString() );
|
|
|
|
/// @brief All-field PartitionEntry
|
|
|
|
PartitionEntry( const QString& label,
|
|
|
|
const QString& uuid,
|
|
|
|
const QString& type,
|
|
|
|
quint64 attributes,
|
|
|
|
const QString& mountPoint,
|
|
|
|
const QString& fs,
|
|
|
|
const QVariantMap& features,
|
|
|
|
const QString& size,
|
|
|
|
const QString& minSize = QString(),
|
|
|
|
const QString& maxSize = QString() );
|
|
|
|
/// @brief Copy PartitionEntry
|
2020-11-02 15:40:32 +01:00
|
|
|
PartitionEntry( const PartitionEntry& e ) = default;
|
2019-04-17 19:16:48 +02:00
|
|
|
|
|
|
|
bool isValid() const
|
|
|
|
{
|
2020-02-14 11:15:57 +01:00
|
|
|
if ( !partSize.isValid()
|
|
|
|
|| ( partMinSize.isValid() && partMaxSize.isValid() && partMinSize > partMaxSize ) )
|
|
|
|
{
|
2019-04-17 19:16:48 +02:00
|
|
|
return false;
|
2020-02-14 11:15:57 +01:00
|
|
|
}
|
2019-04-17 19:16:48 +02:00
|
|
|
return true;
|
|
|
|
}
|
2019-01-07 17:25:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
PartitionLayout();
|
|
|
|
PartitionLayout( const PartitionLayout& layout );
|
|
|
|
~PartitionLayout();
|
|
|
|
|
2020-11-02 21:35:43 +01:00
|
|
|
/** @brief create the configuration from @p config
|
|
|
|
*
|
|
|
|
* @p config is a list of partition entries (in QVariant form,
|
|
|
|
* read from YAML). If no entries are given, then a single
|
|
|
|
* partition is created with the given @p defaultFsType
|
|
|
|
*/
|
|
|
|
void init( FileSystem::Type defaultFsType, const QVariantList& config );
|
2020-06-22 00:02:04 +02:00
|
|
|
bool addEntry( const PartitionEntry& entry );
|
2019-01-07 17:25:22 +01:00
|
|
|
|
2019-01-07 17:26:37 +01:00
|
|
|
/**
|
|
|
|
* @brief Apply the current partition layout to the selected drive space.
|
|
|
|
* @return A list of Partition objects.
|
|
|
|
*/
|
2020-10-30 15:15:30 +01:00
|
|
|
QList< Partition* > createPartitions( Device* dev,
|
|
|
|
qint64 firstSector,
|
|
|
|
qint64 lastSector,
|
|
|
|
QString luksPassphrase,
|
|
|
|
PartitionNode* parent,
|
|
|
|
const PartitionRole& role );
|
2019-01-07 17:26:37 +01:00
|
|
|
|
2019-01-07 17:25:22 +01:00
|
|
|
private:
|
2019-02-22 13:08:59 +01:00
|
|
|
QList< PartitionEntry > m_partLayout;
|
2019-01-07 17:25:22 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PARTITIONLAYOUT_H */
|