API changes, Refactor and Raname to a consistant interface.
This commit is contained in:
parent
4de925735e
commit
6fd0c7a0db
|
@ -32,9 +32,10 @@
|
|||
#include <KLocalizedString>
|
||||
#include <KMountPoint>
|
||||
|
||||
/** Constructs a representation of LVM device with functionning LV as Partition
|
||||
/** Constructs a representation of LVM device with functionning LV as Partitions
|
||||
*
|
||||
* @param name Volume Group name
|
||||
* @param iconname
|
||||
*/
|
||||
LvmDevice::LvmDevice(const QString& name, const QString& iconname)
|
||||
: VolumeManagerDevice(name,
|
||||
|
@ -87,13 +88,15 @@ void LvmDevice::initPartitions()
|
|||
const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
||||
{
|
||||
QList<Partition*> pList;
|
||||
for (const auto &lvPath : lvPathList()) {
|
||||
for (const auto &lvPath : partitionNodes()) {
|
||||
pList.append(scanPartition(lvPath, pTable));
|
||||
}
|
||||
return pList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lvpath
|
||||
* @param pTable
|
||||
* @return sorted Partition (LV) Array
|
||||
*/
|
||||
Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTable) const
|
||||
|
@ -181,6 +184,9 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
|||
return part;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
||||
{
|
||||
QList<LvmDevice*> lvmList;
|
||||
|
@ -193,7 +199,7 @@ QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
|||
qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const
|
||||
{
|
||||
qint64 mSector = 0;
|
||||
QList<QString> lvpathList = lvPathList();
|
||||
QList<QString> lvpathList = partitionNodes();
|
||||
qint32 devIndex = lvpathList.indexOf(lvpath);
|
||||
|
||||
if (devIndex) {
|
||||
|
@ -205,16 +211,21 @@ qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const
|
|||
return mSector;
|
||||
}
|
||||
|
||||
const QStringList LvmDevice::deviceNodeList() const
|
||||
const QStringList LvmDevice::deviceNodes() const
|
||||
{
|
||||
return *PVPathList();
|
||||
}
|
||||
|
||||
const QStringList LvmDevice::lvPathList() const
|
||||
const QStringList LvmDevice::partitionNodes() const
|
||||
{
|
||||
return *LVPathList();
|
||||
}
|
||||
|
||||
qint64 LvmDevice::partitionSize(QString& partitionPath) const
|
||||
{
|
||||
return LVSizeMap()->value(partitionPath);
|
||||
}
|
||||
|
||||
const QStringList LvmDevice::getVGs()
|
||||
{
|
||||
QStringList vgList;
|
||||
|
@ -228,7 +239,7 @@ const QStringList LvmDevice::getVGs()
|
|||
return vgList;
|
||||
}
|
||||
|
||||
QStringList LvmDevice::getPVs(const QString& vgname)
|
||||
const QStringList LvmDevice::getPVs(const QString& vgname)
|
||||
{
|
||||
QStringList devPathList;
|
||||
QString cmdOutput = getField(QStringLiteral("pv_name"), vgname);
|
||||
|
@ -242,7 +253,7 @@ QStringList LvmDevice::getPVs(const QString& vgname)
|
|||
return devPathList;
|
||||
}
|
||||
|
||||
QStringList LvmDevice::getLVs(const QString& vgname)
|
||||
const QStringList LvmDevice::getLVs(const QString& vgname)
|
||||
{
|
||||
QStringList lvPathList;
|
||||
QString cmdOutput = getField(QStringLiteral("lv_path"), vgname);
|
||||
|
|
|
@ -49,15 +49,19 @@ public:
|
|||
~LvmDevice();
|
||||
|
||||
public:
|
||||
const QList<Partition*> scanPartitions(PartitionTable* pTable) const;
|
||||
Partition* scanPartition(const QString& lvPath, PartitionTable* pTable) const;
|
||||
const QStringList deviceNodeList() const override;
|
||||
const QStringList lvPathList() const;
|
||||
const QStringList deviceNodes() const override;
|
||||
const QStringList partitionNodes() const override;
|
||||
qint64 partitionSize(QString& partitionPath) const override;
|
||||
|
||||
static QStringList s_DirtyPVs;
|
||||
|
||||
public:
|
||||
static QList<LvmDevice*> scanSystemLVM();
|
||||
|
||||
static const QStringList getVGs();
|
||||
static const QStringList getPVs(const QString& vgname);
|
||||
static const QStringList getLVs(const QString& vgname);
|
||||
|
||||
static qint64 getPeSize(const QString& vgname);
|
||||
static qint64 getTotalPE(const QString& vgname);
|
||||
static qint64 getAllocatedPE(const QString& vgname);
|
||||
|
@ -67,10 +71,6 @@ public:
|
|||
|
||||
static qint64 getTotalLE(const QString& lvpath);
|
||||
|
||||
static QStringList getPVs(const QString& vgname);
|
||||
static QStringList getLVs(const QString& vgname);
|
||||
static const QStringList getVGs();
|
||||
|
||||
static bool removeLV(Report& report, LvmDevice& dev, Partition& part);
|
||||
static bool createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname);
|
||||
static bool createLVSnapshot(Report& report, LvmDevice& dev, Partition& lvpart, const QString& name, const qint64 extents = 0);
|
||||
|
@ -89,6 +89,9 @@ public:
|
|||
|
||||
protected:
|
||||
void initPartitions() override;
|
||||
const QList<Partition*> scanPartitions(PartitionTable* pTable) const;
|
||||
Partition* scanPartition(const QString& lvPath, PartitionTable* pTable) const;
|
||||
|
||||
qint64 mappedSector(const QString& lvpath, qint64 sector) const override;
|
||||
|
||||
public:
|
||||
|
@ -108,7 +111,8 @@ public:
|
|||
return m_UUID;
|
||||
}
|
||||
|
||||
const QStringList* LVPathList() const {
|
||||
protected:
|
||||
QStringList* LVPathList() const {
|
||||
return m_LVPathList;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
|
||||
#include "util/capacity.h"
|
||||
|
||||
/** Constructs a Device with an empty PartitionTable.
|
||||
/** Constructs a Volume Manager Device with an empty PartitionTable.
|
||||
*/
|
||||
VolumeManagerDevice::VolumeManagerDevice(const QString& name,
|
||||
const QString& devicenode,
|
||||
|
@ -37,7 +37,7 @@ VolumeManagerDevice::VolumeManagerDevice(const QString& name,
|
|||
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||
{
|
||||
QString rval;
|
||||
for (const auto &devNode : deviceNodeList()) {
|
||||
for (const auto &devNode : deviceNodes()) {
|
||||
rval += devNode + QStringLiteral(",");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,10 @@ class CoreBackend;
|
|||
class SmartStatus;
|
||||
class Partition;
|
||||
|
||||
/** A abstract device represeting real physical devices.
|
||||
/** A Volume Manager of real physical devices represented as an abstract device.
|
||||
|
||||
Represents a device like /dev/sda, /dev/sdb1.
|
||||
VolumeManagerDevice is an abstract class of volume manager. e.g: LVM, SoftRAID.
|
||||
a device like /dev/sda, /dev/sdb1.
|
||||
|
||||
Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions.
|
||||
|
||||
|
@ -46,15 +47,38 @@ class LIBKPMCORE_EXPORT VolumeManagerDevice : public Device
|
|||
Q_DISABLE_COPY(VolumeManagerDevice)
|
||||
|
||||
public:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
VolumeManagerDevice(const QString& name, const QString& devicenode, const qint32 logicalSize, const qint64 totalLogical, const QString& iconname = QString(), Device::Type type = Device::Unknown_Device);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
virtual const QStringList deviceNodes() const = 0; /** Return list of physical device or partitions that makes up volumeManagerDevice. */
|
||||
virtual const QStringList partitionNodes() const = 0; /** Return list of partitions on the device. */
|
||||
virtual qint64 partitionSize(QString& partitionPath) const = 0; /** Return size of provided partition in bytes. */
|
||||
|
||||
protected:
|
||||
/**
|
||||
*
|
||||
*/
|
||||
virtual void initPartitions() = 0;
|
||||
virtual const QStringList deviceNodeList() const = 0; /** Return list of physical device or partitions that makes up volumeManagerDevice */
|
||||
/**
|
||||
*
|
||||
*/
|
||||
virtual qint64 mappedSector(const QString& devNode, qint64 sector) const = 0;
|
||||
|
||||
public:
|
||||
/** string deviceNodeList together into comma-sperated list */
|
||||
|
||||
/** string deviceNodes together into comma-sperated list
|
||||
*
|
||||
* */
|
||||
virtual QString prettyDeviceNodeList() const;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
void setTotalLogical(qint64 num) {
|
||||
Q_ASSERT(num > 0);
|
||||
m_TotalLogical = num;
|
||||
|
|
Loading…
Reference in New Issue