kpmcore/src/core/volumemanagerdevice.h

90 lines
2.9 KiB
C
Raw Permalink Normal View History

/*
SPDX-FileCopyrightText: 2016 Chantara Tith <tith.chantara@gmail.com>
SPDX-FileCopyrightText: 2016-2018 Andrius Štikonas <andrius@stikonas.eu>
SPDX-FileCopyrightText: 2019 Caio Jordão Carvalho <caiojcarvalho@gmail.com>
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
#define KPMCORE_VOLUMEMANAGERDEVICE_H
2016-06-08 16:50:40 +01:00
#include "util/libpartitionmanagerexport.h"
#include "core/device.h"
#include <QString>
#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)
public:
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-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-15 07:18:40 +01:00
* @return list of logical partition's path.
*/
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;
protected:
2016-08-11 22:27:58 +01:00
2016-08-15 07:18:40 +01:00
/** Initialize device's partition table and partitions.
*
*/
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-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
*/
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:
2019-04-03 22:23:09 +01:00
static void scanDevices(QList<Device*>& devices);
/** join deviceNodes together into comma-separated list
*
* @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-11 22:27:58 +01:00
* @param n Number of sectors.
*/
2018-04-08 14:45:59 +01:00
void setTotalLogical(qint64 n);
2016-06-08 16:50:40 +01:00
};
#endif