kpmcore/src/core/lvmdevice.h

136 lines
4.8 KiB
C
Raw Normal View History

2016-06-08 16:50:40 +01:00
/*************************************************************************
* Copyright (C) 2016 by Chantara Tith <tith.chantara@gmail.com> *
* *
* 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/>.*
*************************************************************************/
#if !defined(LVMDEVICE__H)
#define LVMDEVICE__H
#include "core/volumemanagerdevice.h"
#include "util/libpartitionmanagerexport.h"
2016-06-23 19:41:55 +01:00
#include "util/report.h"
2016-06-08 16:50:40 +01:00
#include <QString>
#include <QObject>
#include <QtGlobal>
#include <QStringList>
2016-06-08 16:50:40 +01:00
class PartitionTable;
class CreatePartitionTableOperation;
class SmartStatus;
2016-07-31 23:59:18 +01:00
/** Represents LVM Volume Group.
2016-06-08 16:50:40 +01:00
Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions.
@see PartitionTable, Partition
@author Volker Lanz <vl@fidra.de>
*/
class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
{
Q_DISABLE_COPY(LvmDevice)
public:
LvmDevice(const QString& name, const QString& iconname = QString());
~LvmDevice();
2016-06-10 18:00:19 +01:00
public:
const QList<Partition*> scanPartitions(PartitionTable* pTable) const;
2016-07-31 23:59:18 +01:00
Partition* scanPartition(const QString& lvPath, PartitionTable* pTable) const;
const QStringList deviceNodeList() const override;
const QStringList lvPathList() const;
static QStringList s_DirtyPVs;
2016-06-10 18:00:19 +01:00
public:
static QList<LvmDevice*> scanSystemLVM();
static qint64 getPeSize(const QString& vgname);
2016-06-26 11:54:47 +01:00
static qint64 getTotalPE(const QString& vgname);
static qint64 getAllocatedPE(const QString& vgname);
static qint64 getFreePE(const QString& vgname);
static QString getUUID(const QString& vgname);
2016-06-12 14:09:46 +01:00
static QString getField(const QString& fieldName, const QString& vgname = QString());
2016-06-10 18:00:19 +01:00
static qint64 getTotalLE(const QString& lvpath);
static QStringList getPVs(const QString& vgname);
static QStringList getLVs(const QString& vgname);
static const QStringList getVGs();
2016-06-23 19:41:55 +01:00
static bool removeLV(Report& report, LvmDevice& dev, Partition& part);
static bool createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname);
2016-08-01 13:20:20 +01:00
static bool createLVSnapshot(Report& report, LvmDevice& dev, Partition& lvpart, const QString& name, const qint64 extents = 0);
2016-06-25 19:13:09 +01:00
static bool resizeLV(Report& report, LvmDevice& dev, Partition& part);
static bool deactivateLV(Report& report, const LvmDevice& dev, const Partition& part);
2016-08-08 07:05:35 +01:00
static bool activateLV(Report& report, LvmDevice& dev, Partition& part);
2016-06-23 19:41:55 +01:00
static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath);
static bool movePV(Report& report, LvmDevice& dev, const QString& pvPath, const QStringList& destinations = QStringList());
2016-06-18 21:58:40 +01:00
static bool removeVG(Report& report, LvmDevice& dev);
static bool createVG(Report& report, const QString vgname, const QStringList pvlist, const qint32 peSize = 4); // peSize in megabytes
2016-08-08 06:52:50 +01:00
static bool deactivateVG(Report& report, const LvmDevice& dev);
2016-08-08 07:05:35 +01:00
static bool activateVG(Report& report, const LvmDevice& dev);
2016-06-29 16:08:32 +01:00
2016-06-10 18:00:19 +01:00
protected:
void initPartitions() override;
qint64 mappedSector(const QString& lvpath, qint64 sector) const override;
2016-06-08 16:50:40 +01:00
public:
qint64 peSize() const {
2016-06-08 16:50:40 +01:00
return m_peSize;
}
2016-06-26 11:54:47 +01:00
qint64 totalPE() const {
2016-06-08 16:50:40 +01:00
return m_totalPE;
}
qint64 allocatedPE() const {
2016-06-08 16:50:40 +01:00
return m_allocPE;
}
qint64 freePE() const {
2016-06-08 16:50:40 +01:00
return m_freePE;
}
2016-06-10 18:00:19 +01:00
QString UUID() const {
return m_UUID;
}
2016-06-08 16:50:40 +01:00
const QStringList* LVPathList() const {
return m_LVPathList;
}
QStringList* PVPathList() const {
return m_PVPathList;
}
QMap<QString, qint64>* LVSizeMap() const {
return m_LVSizeMap;
}
2016-06-08 16:50:40 +01:00
private:
qint64 m_peSize;
2016-06-26 11:54:47 +01:00
qint64 m_totalPE;
qint64 m_allocPE;
qint64 m_freePE;
QString m_UUID;
mutable QStringList* m_LVPathList;
mutable QStringList* m_PVPathList;
mutable QMap<QString, qint64>* m_LVSizeMap;
2016-06-08 16:50:40 +01:00
};
#endif