2016-06-08 16:50:40 +01:00
|
|
|
/*************************************************************************
|
2016-06-18 20:54:52 +01:00
|
|
|
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
|
|
|
|
* *
|
2016-06-08 16:50:40 +01:00
|
|
|
* This program is free software; you can redistribute it and/or *
|
|
|
|
* modify it under the terms of the GNU General Public License as *
|
|
|
|
* published by the Free Software Foundation; either version 3 of *
|
|
|
|
* the License, or (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
* This program is distributed in the hope that it will be useful, *
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
|
|
* GNU General Public License for more details. *
|
|
|
|
* *
|
|
|
|
* You should have received a copy of the GNU General Public License *
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.*
|
|
|
|
*************************************************************************/
|
|
|
|
|
2017-09-10 20:12:52 +01:00
|
|
|
#if !defined(KPMCORE_VOLUMEMANAGERDEVICE_H)
|
2016-06-08 16:50:40 +01:00
|
|
|
|
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>
|
|
|
|
|
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:
|
2016-08-11 22:27:58 +01:00
|
|
|
|
2017-09-11 13:41:03 +01:00
|
|
|
VolumeManagerDevice(const QString& name, const QString& deviceNode, const qint64 logicalSize, const qint64 totalLogical, const QString& iconName = QString(), Device::Type type = Device::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
|
|
|
*/
|
2016-08-15 07:18:40 +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
|
|
|
*/
|
2016-08-15 07:18:40 +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
|
|
|
|
|
|
|
/** string deviceNodes together into comma-sperated list
|
|
|
|
*
|
2016-08-11 22:27:58 +01:00
|
|
|
* @return comma-seperated list of deviceNodes
|
|
|
|
*/
|
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
|
|
|
*/
|
2016-08-11 22:27:58 +01:00
|
|
|
void setTotalLogical(qint64 n) {
|
|
|
|
Q_ASSERT(n > 0);
|
|
|
|
m_TotalLogical = n;
|
2016-08-07 21:30:47 +01:00
|
|
|
}
|
2016-06-08 16:50:40 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|