2015-06-04 01:29:22 +01:00
|
|
|
/*************************************************************************
|
|
|
|
* Copyright (C) 2012 by Volker Lanz <vl@fidra.de> *
|
2016-06-01 21:00:31 +01:00
|
|
|
* Copyright (C) 2016 by Andrius Štikonas <andrius@stikonas.eu> *
|
2015-06-04 01:29:22 +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_LVM2_PV_H)
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2017-09-10 20:12:52 +01:00
|
|
|
#define KPMCORE_LVM2_PV_H
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
#include "util/libpartitionmanagerexport.h"
|
|
|
|
|
2016-09-07 14:36:25 +01:00
|
|
|
#include "core/partition.h"
|
2015-06-04 01:29:22 +01:00
|
|
|
#include "fs/filesystem.h"
|
|
|
|
|
2016-04-18 17:14:31 +01:00
|
|
|
#include <QtGlobal>
|
2015-06-04 01:29:22 +01:00
|
|
|
|
|
|
|
class Report;
|
|
|
|
class QString;
|
|
|
|
|
2016-11-02 23:06:55 +00:00
|
|
|
/** Stores information about LVM PV or potentially encrypted LVM PV
|
|
|
|
* @author Andrius Štikonas <andrius@stikonas.eu>
|
|
|
|
*/
|
|
|
|
|
|
|
|
class LvmPV
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LvmPV(const QString vgName, const Partition* p, bool isLuks = false);
|
|
|
|
|
|
|
|
const QString vgName() const {
|
|
|
|
return m_vgName;
|
|
|
|
}
|
|
|
|
|
2016-11-03 13:39:16 +00:00
|
|
|
QPointer<const Partition> partition() const {
|
2016-11-02 23:06:55 +00:00
|
|
|
return m_p;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isLuks() const {
|
|
|
|
return m_isLuks;
|
|
|
|
}
|
|
|
|
|
2016-11-03 14:21:18 +00:00
|
|
|
void setLuks(bool luks) {
|
|
|
|
m_isLuks = luks;
|
|
|
|
}
|
|
|
|
|
2016-11-02 23:06:55 +00:00
|
|
|
private:
|
|
|
|
QString m_vgName;
|
2016-11-03 13:39:16 +00:00
|
|
|
QPointer<const Partition> m_p;
|
2016-11-02 23:06:55 +00:00
|
|
|
bool m_isLuks;
|
|
|
|
};
|
|
|
|
|
2016-11-03 13:26:14 +00:00
|
|
|
namespace LVM {
|
2018-05-09 08:09:17 +01:00
|
|
|
/** Class to access a global LVM PV list.
|
|
|
|
@author Caio Carvalho <caiojcarvalho@gmail.com>
|
|
|
|
*/
|
|
|
|
class LIBKPMCORE_EXPORT pvList
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static QList<LvmPV> &list() {
|
|
|
|
return m_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
pvList() { }
|
|
|
|
|
|
|
|
private:
|
|
|
|
static QList<LvmPV> m_list;
|
|
|
|
};
|
2016-11-03 13:26:14 +00:00
|
|
|
}
|
2016-11-02 23:06:55 +00:00
|
|
|
|
2015-06-04 01:29:22 +01:00
|
|
|
namespace FS
|
|
|
|
{
|
2015-07-13 15:16:36 +01:00
|
|
|
/** LVM2 physical volume.
|
2016-02-25 23:29:33 +00:00
|
|
|
@author Andrius Štikonas <andrius@stikonas.eu>
|
2015-07-13 15:16:36 +01:00
|
|
|
*/
|
|
|
|
class LIBKPMCORE_EXPORT lvm2_pv : public FileSystem
|
|
|
|
{
|
2016-09-10 22:08:21 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
public:
|
|
|
|
lvm2_pv(qint64 firstsector, qint64 lastsector, qint64 sectorsused, const QString& label);
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
public:
|
2016-05-17 18:01:31 +01:00
|
|
|
void init() override;
|
2016-09-05 14:48:36 +01:00
|
|
|
void scan(const QString& deviceNode) override;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-06-24 00:13:31 +01:00
|
|
|
qint64 readUsedCapacity(const QString& deviceNode) const override;
|
2016-05-17 18:01:31 +01:00
|
|
|
bool check(Report& report, const QString& deviceNode) const override;
|
2016-09-05 12:10:56 +01:00
|
|
|
bool create(Report& report, const QString& deviceNode) override;
|
2016-05-17 18:01:31 +01:00
|
|
|
bool remove(Report& report, const QString& deviceNode) const override;
|
2016-05-24 21:13:23 +01:00
|
|
|
bool resize(Report& report, const QString& deviceNode, qint64 length) const override;
|
2016-10-30 01:46:38 +01:00
|
|
|
bool resizeOnline(Report& report, const QString& deviceNode, const QString& mountPoint, qint64 length) const override;
|
2016-05-17 18:01:31 +01:00
|
|
|
// bool writeLabel(Report& report, const QString& deviceNode, const QString& newLabel) override;
|
|
|
|
bool updateUUID(Report& report, const QString& deviceNode) const override;
|
2016-06-24 00:13:31 +01:00
|
|
|
QString readUUID(const QString& deviceNode) const override;
|
|
|
|
|
2016-09-18 02:40:30 +01:00
|
|
|
bool canMount(const QString& deviceNode, const QString& mountPoint) const override;
|
2016-06-24 00:13:31 +01:00
|
|
|
bool canUnmount(const QString& deviceNode) const override;
|
|
|
|
|
|
|
|
bool mount(Report& report, const QString& deviceNode, const QString& mountPoint) override; // mountPoint == VG name
|
|
|
|
bool unmount(Report& report, const QString& deviceNode) override;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-05-25 18:03:03 +01:00
|
|
|
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportGetUsed() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_GetUsed;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportGetLabel() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_GetLabel;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportCreate() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Create;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportGrow() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Grow;
|
|
|
|
}
|
2016-10-30 01:46:38 +01:00
|
|
|
CommandSupportType supportGrowOnline() const override {
|
|
|
|
return m_Grow;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportShrink() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Shrink;
|
|
|
|
}
|
2016-10-30 01:46:38 +01:00
|
|
|
CommandSupportType supportShrinkOnline() const override {
|
|
|
|
return m_Shrink;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportMove() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Move;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportCheck() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Check;
|
|
|
|
}
|
2016-10-30 01:46:38 +01:00
|
|
|
CommandSupportType supportCheckOnline() const override {
|
|
|
|
return m_Check;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportCopy() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Copy;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportBackup() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_Backup;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportSetLabel() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_SetLabel;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportUpdateUUID() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_UpdateUUID;
|
|
|
|
}
|
2016-05-17 18:01:31 +01:00
|
|
|
CommandSupportType supportGetUUID() const override {
|
2015-07-13 15:16:36 +01:00
|
|
|
return m_GetUUID;
|
|
|
|
}
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-05-17 18:01:31 +01:00
|
|
|
qint64 maxCapacity() const override;
|
|
|
|
SupportTool supportToolName() const override;
|
|
|
|
bool supportToolFound() const override;
|
2015-06-04 01:29:22 +01:00
|
|
|
|
2016-09-05 14:48:36 +01:00
|
|
|
static QString getpvField(const QString& fieldName, const QString& deviceNode = QString());
|
|
|
|
|
2016-07-08 10:19:33 +01:00
|
|
|
static qint64 getTotalPE(const QString& deviceNode);
|
|
|
|
static qint64 getAllocatedPE(const QString& deviceNode);
|
2016-05-23 11:29:33 +01:00
|
|
|
static QString getVGName(const QString& deviceNode);
|
2016-11-02 23:06:55 +00:00
|
|
|
static QList<LvmPV> getPVinNode(const PartitionNode* parent);
|
|
|
|
static QList<LvmPV> getPVs(const QList<Device*>& devices);
|
2016-09-05 14:48:36 +01:00
|
|
|
|
2017-09-11 00:29:30 +01:00
|
|
|
qint64 allocatedPE() const { return m_AllocatedPE; }
|
|
|
|
qint64 freePE() const { return m_TotalPE - m_AllocatedPE; }
|
|
|
|
qint64 totalPE() const { return m_TotalPE; }
|
|
|
|
qint64 peSize() const { return m_PESize; }
|
2016-06-24 00:13:31 +01:00
|
|
|
|
2016-09-18 02:40:30 +01:00
|
|
|
private:
|
|
|
|
void getPESize(const QString& deviceNode); // return PE size in bytes
|
|
|
|
|
2015-07-13 15:16:36 +01:00
|
|
|
public:
|
|
|
|
static CommandSupportType m_GetUsed;
|
|
|
|
static CommandSupportType m_GetLabel;
|
|
|
|
static CommandSupportType m_Create;
|
|
|
|
static CommandSupportType m_Grow;
|
|
|
|
static CommandSupportType m_Shrink;
|
|
|
|
static CommandSupportType m_Move;
|
|
|
|
static CommandSupportType m_Check;
|
|
|
|
static CommandSupportType m_Copy;
|
|
|
|
static CommandSupportType m_Backup;
|
|
|
|
static CommandSupportType m_SetLabel;
|
|
|
|
static CommandSupportType m_UpdateUUID;
|
|
|
|
static CommandSupportType m_GetUUID;
|
2016-09-04 11:55:49 +01:00
|
|
|
|
2016-09-05 14:48:36 +01:00
|
|
|
private:
|
|
|
|
qint64 m_PESize;
|
2016-09-08 01:42:04 +01:00
|
|
|
qint64 m_TotalPE;
|
|
|
|
qint64 m_AllocatedPE;
|
2015-07-13 15:16:36 +01:00
|
|
|
};
|
2015-06-04 01:29:22 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|