2020-09-20 20:33:16 +01:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
|
|
|
|
SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
|
2020-10-01 00:33:19 +01:00
|
|
|
SPDX-FileCopyrightText: 2019 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
|
2020-09-20 20:33:16 +01:00
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
*/
|
2016-06-08 16:50:40 +01:00
|
|
|
|
2018-04-08 14:45:59 +01:00
|
|
|
#ifndef KPMCORE_VOLUMEMANAGERDEVICE_H
|
2017-09-10 20:12:52 +01:00
|
|
|
#define KPMCORE_VOLUMEMANAGERDEVICE_H
|
2016-06-08 16:50:40 +01:00
|
|
|
|
|
|
|
#include "util/libpartitionmanagerexport.h"
|
|
|
|
#include "core/device.h"
|
|
|
|
|
|
|
|
#include <QString>
|
2016-08-07 21:30:47 +01:00
|
|
|
#include <QStringList>
|
2016-06-08 16:50:40 +01:00
|
|
|
#include <QObject>
|
|
|
|
#include <QtGlobal>
|
|
|
|
|
2018-04-09 02:40:24 +01:00
|
|
|
class VolumeManagerDevicePrivate;
|
|
|
|
|
2016-08-15 07:18:40 +01:00
|
|
|
/** A Volume Manager of physical devices represented as an abstract device.
|
|
|
|
*
|
|
|
|
* VolumeManagerDevice is an abstract device class for volume manager. e.g: LVM, SoftRAID.
|
|
|
|
* example of physical device: /dev/sda, /dev/sdb1.
|
|
|
|
*
|
|
|
|
* Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions.
|
|
|
|
*
|
|
|
|
* @see Device, PartitionTable, Partition
|
|
|
|
*/
|
2016-06-08 16:50:40 +01:00
|
|
|
class LIBKPMCORE_EXPORT VolumeManagerDevice : public Device
|
|
|
|
{
|
|
|
|
Q_DISABLE_COPY(VolumeManagerDevice)
|
|
|
|
|
2016-08-07 21:30:47 +01:00
|
|
|
public:
|
2018-04-09 02:57:45 +01:00
|
|
|
VolumeManagerDevice(std::shared_ptr<VolumeManagerDevicePrivate> d, const QString& name, const QString& deviceNode, const qint64 logicalSectorSize, const qint64 totalLogical, const QString& iconName = QString(), Device::Type type = Device::Type::Unknown_Device);
|
2016-08-10 03:13:53 +01:00
|
|
|
|
2016-08-11 22:27:58 +01:00
|
|
|
/**
|
2016-08-15 07:18:40 +01:00
|
|
|
* @return list of physical device's path that makes up volumeManagerDevice.(e.g: /dev/sda, /dev/sdb1)
|
2016-08-11 22:27:58 +01:00
|
|
|
*/
|
|
|
|
virtual const QStringList deviceNodes() const = 0;
|
|
|
|
|
2016-08-10 03:13:53 +01:00
|
|
|
/**
|
2016-08-15 07:18:40 +01:00
|
|
|
* @return list of logical partition's path.
|
2016-08-10 03:13:53 +01:00
|
|
|
*/
|
2018-04-09 03:14:30 +01:00
|
|
|
virtual const QStringList& partitionNodes() const = 0;
|
2016-08-11 22:27:58 +01:00
|
|
|
|
|
|
|
/**
|
2016-08-15 07:18:40 +01:00
|
|
|
* @return size of logical partition at the given path in bytes.
|
2016-08-11 22:27:58 +01:00
|
|
|
*/
|
2016-08-15 07:18:40 +01:00
|
|
|
virtual qint64 partitionSize(QString& partitionPath) const = 0;
|
2016-08-10 03:13:53 +01:00
|
|
|
|
|
|
|
protected:
|
2016-08-11 22:27:58 +01:00
|
|
|
|
2016-08-15 07:18:40 +01:00
|
|
|
/** Initialize device's partition table and partitions.
|
2016-08-10 03:13:53 +01:00
|
|
|
*
|
|
|
|
*/
|
2016-08-07 21:30:47 +01:00
|
|
|
virtual void initPartitions() = 0;
|
2016-08-11 22:27:58 +01:00
|
|
|
|
2016-08-15 07:18:40 +01:00
|
|
|
/** absolute sector as represented inside the device's partitionTable
|
|
|
|
*
|
|
|
|
* For VolumeMangerDevice to works with the rest of the codebase, partitions are stringed
|
|
|
|
* one after another to create a representation of PartitionTable and partition just like
|
|
|
|
* real disk device.
|
2016-08-10 03:13:53 +01:00
|
|
|
*
|
2016-08-15 07:18:40 +01:00
|
|
|
* @param partitionPath logical partition path
|
|
|
|
* @sector sector value to be mapped (if 0, will return start sector of the partition)
|
|
|
|
* @return absolute sector value as represented inside device's partitionTable
|
2016-08-10 03:13:53 +01:00
|
|
|
*/
|
2018-04-08 14:45:59 +01:00
|
|
|
virtual qint64 mappedSector(const QString& partitionPath, qint64 sector) const = 0;
|
2016-06-08 16:50:40 +01:00
|
|
|
|
|
|
|
public:
|
2016-08-10 03:13:53 +01:00
|
|
|
|
2019-04-03 22:23:09 +01:00
|
|
|
static void scanDevices(QList<Device*>& devices);
|
|
|
|
|
2018-04-02 13:13:16 +01:00
|
|
|
/** join deviceNodes together into comma-separated list
|
2016-08-10 03:13:53 +01:00
|
|
|
*
|
2018-04-02 13:13:16 +01:00
|
|
|
* @return comma-separated list of deviceNodes
|
2016-08-11 22:27:58 +01:00
|
|
|
*/
|
2016-06-12 14:09:46 +01:00
|
|
|
virtual QString prettyDeviceNodeList() const;
|
|
|
|
|
2016-08-11 22:27:58 +01:00
|
|
|
/** Resize device total number of logical sectors.
|
2016-08-10 03:13:53 +01:00
|
|
|
*
|
2016-08-11 22:27:58 +01:00
|
|
|
* @param n Number of sectors.
|
2016-08-10 03:13:53 +01:00
|
|
|
*/
|
2018-04-08 14:45:59 +01:00
|
|
|
void setTotalLogical(qint64 n);
|
2016-06-08 16:50:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|