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 <KLocalizedString>
|
||||||
#include <KMountPoint>
|
#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 name Volume Group name
|
||||||
|
* @param iconname
|
||||||
*/
|
*/
|
||||||
LvmDevice::LvmDevice(const QString& name, const QString& iconname)
|
LvmDevice::LvmDevice(const QString& name, const QString& iconname)
|
||||||
: VolumeManagerDevice(name,
|
: VolumeManagerDevice(name,
|
||||||
|
@ -87,13 +88,15 @@ void LvmDevice::initPartitions()
|
||||||
const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
||||||
{
|
{
|
||||||
QList<Partition*> pList;
|
QList<Partition*> pList;
|
||||||
for (const auto &lvPath : lvPathList()) {
|
for (const auto &lvPath : partitionNodes()) {
|
||||||
pList.append(scanPartition(lvPath, pTable));
|
pList.append(scanPartition(lvPath, pTable));
|
||||||
}
|
}
|
||||||
return pList;
|
return pList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param lvpath
|
||||||
|
* @param pTable
|
||||||
* @return sorted Partition (LV) Array
|
* @return sorted Partition (LV) Array
|
||||||
*/
|
*/
|
||||||
Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTable) const
|
Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTable) const
|
||||||
|
@ -181,6 +184,9 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
return part;
|
return part;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
||||||
{
|
{
|
||||||
QList<LvmDevice*> lvmList;
|
QList<LvmDevice*> lvmList;
|
||||||
|
@ -193,7 +199,7 @@ QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
||||||
qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const
|
qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const
|
||||||
{
|
{
|
||||||
qint64 mSector = 0;
|
qint64 mSector = 0;
|
||||||
QList<QString> lvpathList = lvPathList();
|
QList<QString> lvpathList = partitionNodes();
|
||||||
qint32 devIndex = lvpathList.indexOf(lvpath);
|
qint32 devIndex = lvpathList.indexOf(lvpath);
|
||||||
|
|
||||||
if (devIndex) {
|
if (devIndex) {
|
||||||
|
@ -205,16 +211,21 @@ qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const
|
||||||
return mSector;
|
return mSector;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList LvmDevice::deviceNodeList() const
|
const QStringList LvmDevice::deviceNodes() const
|
||||||
{
|
{
|
||||||
return *PVPathList();
|
return *PVPathList();
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList LvmDevice::lvPathList() const
|
const QStringList LvmDevice::partitionNodes() const
|
||||||
{
|
{
|
||||||
return *LVPathList();
|
return *LVPathList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qint64 LvmDevice::partitionSize(QString& partitionPath) const
|
||||||
|
{
|
||||||
|
return LVSizeMap()->value(partitionPath);
|
||||||
|
}
|
||||||
|
|
||||||
const QStringList LvmDevice::getVGs()
|
const QStringList LvmDevice::getVGs()
|
||||||
{
|
{
|
||||||
QStringList vgList;
|
QStringList vgList;
|
||||||
|
@ -228,7 +239,7 @@ const QStringList LvmDevice::getVGs()
|
||||||
return vgList;
|
return vgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList LvmDevice::getPVs(const QString& vgname)
|
const QStringList LvmDevice::getPVs(const QString& vgname)
|
||||||
{
|
{
|
||||||
QStringList devPathList;
|
QStringList devPathList;
|
||||||
QString cmdOutput = getField(QStringLiteral("pv_name"), vgname);
|
QString cmdOutput = getField(QStringLiteral("pv_name"), vgname);
|
||||||
|
@ -242,7 +253,7 @@ QStringList LvmDevice::getPVs(const QString& vgname)
|
||||||
return devPathList;
|
return devPathList;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList LvmDevice::getLVs(const QString& vgname)
|
const QStringList LvmDevice::getLVs(const QString& vgname)
|
||||||
{
|
{
|
||||||
QStringList lvPathList;
|
QStringList lvPathList;
|
||||||
QString cmdOutput = getField(QStringLiteral("lv_path"), vgname);
|
QString cmdOutput = getField(QStringLiteral("lv_path"), vgname);
|
||||||
|
|
|
@ -49,15 +49,19 @@ public:
|
||||||
~LvmDevice();
|
~LvmDevice();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const QList<Partition*> scanPartitions(PartitionTable* pTable) const;
|
const QStringList deviceNodes() const override;
|
||||||
Partition* scanPartition(const QString& lvPath, PartitionTable* pTable) const;
|
const QStringList partitionNodes() const override;
|
||||||
const QStringList deviceNodeList() const override;
|
qint64 partitionSize(QString& partitionPath) const override;
|
||||||
const QStringList lvPathList() const;
|
|
||||||
static QStringList s_DirtyPVs;
|
static QStringList s_DirtyPVs;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static QList<LvmDevice*> scanSystemLVM();
|
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 getPeSize(const QString& vgname);
|
||||||
static qint64 getTotalPE(const QString& vgname);
|
static qint64 getTotalPE(const QString& vgname);
|
||||||
static qint64 getAllocatedPE(const QString& vgname);
|
static qint64 getAllocatedPE(const QString& vgname);
|
||||||
|
@ -67,10 +71,6 @@ public:
|
||||||
|
|
||||||
static qint64 getTotalLE(const QString& lvpath);
|
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 removeLV(Report& report, LvmDevice& dev, Partition& part);
|
||||||
static bool createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname);
|
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);
|
static bool createLVSnapshot(Report& report, LvmDevice& dev, Partition& lvpart, const QString& name, const qint64 extents = 0);
|
||||||
|
@ -89,6 +89,9 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initPartitions() override;
|
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;
|
qint64 mappedSector(const QString& lvpath, qint64 sector) const override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -108,7 +111,8 @@ public:
|
||||||
return m_UUID;
|
return m_UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QStringList* LVPathList() const {
|
protected:
|
||||||
|
QStringList* LVPathList() const {
|
||||||
return m_LVPathList;
|
return m_LVPathList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
#include "util/capacity.h"
|
#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,
|
VolumeManagerDevice::VolumeManagerDevice(const QString& name,
|
||||||
const QString& devicenode,
|
const QString& devicenode,
|
||||||
|
@ -37,7 +37,7 @@ VolumeManagerDevice::VolumeManagerDevice(const QString& name,
|
||||||
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
QString VolumeManagerDevice::prettyDeviceNodeList() const
|
||||||
{
|
{
|
||||||
QString rval;
|
QString rval;
|
||||||
for (const auto &devNode : deviceNodeList()) {
|
for (const auto &devNode : deviceNodes()) {
|
||||||
rval += devNode + QStringLiteral(",");
|
rval += devNode + QStringLiteral(",");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,10 @@ class CoreBackend;
|
||||||
class SmartStatus;
|
class SmartStatus;
|
||||||
class Partition;
|
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.
|
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)
|
Q_DISABLE_COPY(VolumeManagerDevice)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
VolumeManagerDevice(const QString& name, const QString& devicenode, const qint32 logicalSize, const qint64 totalLogical, const QString& iconname = QString(), Device::Type type = Device::Unknown_Device);
|
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 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;
|
virtual qint64 mappedSector(const QString& devNode, qint64 sector) const = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/** string deviceNodeList together into comma-sperated list */
|
|
||||||
|
/** string deviceNodes together into comma-sperated list
|
||||||
|
*
|
||||||
|
* */
|
||||||
virtual QString prettyDeviceNodeList() const;
|
virtual QString prettyDeviceNodeList() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
void setTotalLogical(qint64 num) {
|
void setTotalLogical(qint64 num) {
|
||||||
Q_ASSERT(num > 0);
|
Q_ASSERT(num > 0);
|
||||||
m_TotalLogical = num;
|
m_TotalLogical = num;
|
||||||
|
|
Loading…
Reference in New Issue