2020-09-30 23:58:54 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2017-2020 Andrius Štikonas <andrius@stikonas.eu>
|
2020-10-01 00:33:19 +01:00
|
|
|
SPDX-FileCopyrightText: 2018 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
2017-09-17 15:33:25 +01:00
|
|
|
|
2020-09-30 23:58:54 +01:00
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SFDISKBACKEND__H
|
2017-09-17 15:33:25 +01:00
|
|
|
#define SFDISKBACKEND__H
|
|
|
|
|
|
|
|
#include "backend/corebackend.h"
|
|
|
|
#include "core/partition.h"
|
|
|
|
#include "fs/filesystem.h"
|
|
|
|
|
|
|
|
#include <QList>
|
|
|
|
#include <QVariant>
|
|
|
|
|
|
|
|
class Device;
|
2020-10-02 23:00:40 +01:00
|
|
|
class ExternalCommand;
|
2020-06-19 01:52:16 +01:00
|
|
|
class Partition;
|
2017-09-17 15:33:25 +01:00
|
|
|
class KPluginFactory;
|
|
|
|
class QString;
|
|
|
|
|
|
|
|
/** Backend plugin for sfdisk
|
|
|
|
|
|
|
|
@author Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
*/
|
|
|
|
class SfdiskBackend : public CoreBackend
|
|
|
|
{
|
|
|
|
Q_DISABLE_COPY(SfdiskBackend)
|
|
|
|
|
2020-11-16 16:14:52 +00:00
|
|
|
public:
|
2017-09-17 15:33:25 +01:00
|
|
|
SfdiskBackend(QObject* parent, const QList<QVariant>& args);
|
|
|
|
|
|
|
|
public:
|
|
|
|
void initFSSupport() override;
|
|
|
|
|
|
|
|
QList<Device*> scanDevices(bool excludeReadOnly = false) override;
|
2019-02-09 15:40:06 +00:00
|
|
|
QList<Device*> scanDevices(const ScanFlags scanFlags) override;
|
2018-03-31 14:44:40 +01:00
|
|
|
std::unique_ptr<CoreBackendDevice> openDevice(const Device& d) override;
|
|
|
|
std::unique_ptr<CoreBackendDevice> openDeviceExclusive(const Device& d) override;
|
|
|
|
bool closeDevice(std::unique_ptr<CoreBackendDevice> coreDevice) override;
|
2017-09-17 15:33:25 +01:00
|
|
|
Device* scanDevice(const QString& deviceNode) override;
|
|
|
|
FileSystem::Type detectFileSystem(const QString& partitionPath) override;
|
2018-01-31 15:04:55 +00:00
|
|
|
QString readLabel(const QString& deviceNode) const override;
|
|
|
|
QString readUUID(const QString& deviceNode) const override;
|
2017-09-17 15:33:25 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
static void readSectorsUsed(const Device& d, Partition& p, const QString& mountPoint);
|
|
|
|
void scanDevicePartitions(Device& d, const QJsonArray& jsonPartitions);
|
2020-10-03 13:25:05 +01:00
|
|
|
Partition* scanPartition(Device& d, const QString& partitionNode, const qint64 firstSector, const qint64 lastSector, const QString& partitionType, const bool bootable);
|
2020-10-03 15:14:51 +01:00
|
|
|
void scanWholeDevicePartition(Device& d);
|
2020-10-03 13:25:05 +01:00
|
|
|
static void setupPartitionInfo(const Device& d, Partition* partition, const QJsonObject& partitionObject);
|
2018-07-10 00:01:34 +01:00
|
|
|
bool updateDevicePartitionTable(Device& d, const QJsonObject& jsonPartitionTable);
|
2017-09-17 15:33:25 +01:00
|
|
|
static PartitionTable::Flags availableFlags(PartitionTable::TableType type);
|
2020-10-02 22:36:19 +01:00
|
|
|
static FileSystem::Type fileSystemNameToType(const QString& fileSystemName, const QString& version);
|
2020-10-02 23:00:40 +01:00
|
|
|
static FileSystem::Type runDetectFileSystemCommand(ExternalCommand& command, QString& typeRegExp, QString& versionRegExp, QString& name);
|
2017-09-17 15:33:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|