Make variable names slightly more consistent thruoght kmpcore.
Add more doxygen comments.
This commit is contained in:
parent
69647e816e
commit
8a3c11774c
|
@ -72,24 +72,24 @@ static qint32 getPhysicalSectorSize(const QString& device_node)
|
||||||
|
|
||||||
/** Constructs a Disk Device with an empty PartitionTable.
|
/** Constructs a Disk Device with an empty PartitionTable.
|
||||||
@param name the Device's name, usually some string defined by the manufacturer
|
@param name the Device's name, usually some string defined by the manufacturer
|
||||||
@param devicenode the Device's node, for example "/dev/sda"
|
@param deviceNode the Device's node, for example "/dev/sda"
|
||||||
@param heads the number of heads in CHS notation
|
@param heads the number of heads in CHS notation
|
||||||
@param numSectors the number of sectors in CHS notation
|
@param numSectors the number of sectors in CHS notation
|
||||||
@param cylinders the number of cylinders in CHS notation
|
@param cylinders the number of cylinders in CHS notation
|
||||||
@param sectorSize the size of a sector in bytes
|
@param sectorSize the size of a sector in bytes
|
||||||
*/
|
*/
|
||||||
DiskDevice::DiskDevice(const QString& name,
|
DiskDevice::DiskDevice(const QString& name,
|
||||||
const QString& devicenode,
|
const QString& deviceNode,
|
||||||
qint32 heads,
|
qint32 heads,
|
||||||
qint32 numSectors,
|
qint32 numSectors,
|
||||||
qint32 cylinders,
|
qint32 cylinders,
|
||||||
qint32 sectorSize,
|
qint32 sectorSize,
|
||||||
const QString& iconname)
|
const QString& iconName)
|
||||||
: Device(name, devicenode, sectorSize, (static_cast<qint64>(heads) * cylinders * numSectors), iconname, Device::Disk_Device)
|
: Device(name, deviceNode, sectorSize, (static_cast<qint64>(heads) * cylinders * numSectors), iconName, Device::Disk_Device)
|
||||||
, m_Heads(heads)
|
, m_Heads(heads)
|
||||||
, m_SectorsPerTrack(numSectors)
|
, m_SectorsPerTrack(numSectors)
|
||||||
, m_Cylinders(cylinders)
|
, m_Cylinders(cylinders)
|
||||||
, m_LogicalSectorSize(sectorSize)
|
, m_LogicalSectorSize(sectorSize)
|
||||||
, m_PhysicalSectorSize(getPhysicalSectorSize(devicenode))
|
, m_PhysicalSectorSize(getPhysicalSectorSize(deviceNode))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ class LIBKPMCORE_EXPORT DiskDevice : public Device
|
||||||
friend class CoreBackend;
|
friend class CoreBackend;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DiskDevice(const QString& name, const QString& devicenode, qint32 heads, qint32 numSectors, qint32 cylinders, qint32 sectorSize, const QString& iconname = QString());
|
DiskDevice(const QString& name, const QString& deviceNode, qint32 heads, qint32 numSectors, qint32 cylinders, qint32 sectorSize, const QString& iconName = QString());
|
||||||
|
|
||||||
public:
|
public:
|
||||||
qint32 heads() const {
|
qint32 heads() const {
|
||||||
|
|
|
@ -35,24 +35,24 @@
|
||||||
|
|
||||||
/** Constructs a representation of LVM device with functionning LV as Partitions
|
/** Constructs a representation of LVM device with functionning LV as Partitions
|
||||||
*
|
*
|
||||||
* @param name Volume Group name
|
* @param vgName Volume Group name
|
||||||
* @param iconname
|
* @param iconName Icon representing LVM Volume group
|
||||||
*/
|
*/
|
||||||
LvmDevice::LvmDevice(const QString& name, const QString& iconname)
|
LvmDevice::LvmDevice(const QString& vgName, const QString& iconName)
|
||||||
: VolumeManagerDevice(name,
|
: VolumeManagerDevice(vgName,
|
||||||
(QStringLiteral("/dev/") + name),
|
(QStringLiteral("/dev/") + vgName),
|
||||||
getPeSize(name),
|
getPeSize(vgName),
|
||||||
getTotalPE(name),
|
getTotalPE(vgName),
|
||||||
iconname,
|
iconName,
|
||||||
Device::LVM_Device)
|
Device::LVM_Device)
|
||||||
{
|
{
|
||||||
m_peSize = logicalSize();
|
m_peSize = logicalSize();
|
||||||
m_totalPE = totalLogical();
|
m_totalPE = totalLogical();
|
||||||
m_freePE = getFreePE(name);
|
m_freePE = getFreePE(vgName);
|
||||||
m_allocPE = m_totalPE - m_freePE;
|
m_allocPE = m_totalPE - m_freePE;
|
||||||
m_UUID = getUUID(name);
|
m_UUID = getUUID(vgName);
|
||||||
m_PVPathList = new QStringList(getPVs(name));
|
m_PVPathList = new QStringList(getPVs(vgName));
|
||||||
m_LVPathList = new QStringList(getLVs(name));
|
m_LVPathList = new QStringList(getLVs(vgName));
|
||||||
m_LVSizeMap = new QMap<QString, qint64>();
|
m_LVSizeMap = new QMap<QString, qint64>();
|
||||||
|
|
||||||
initPartitions();
|
initPartitions();
|
||||||
|
@ -96,11 +96,11 @@ const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param lvpath
|
* @param lvPath LVM Logical Volume path
|
||||||
* @param pTable
|
* @param pTable Abstract partition table representing partitions of LVM Volume Group
|
||||||
* @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
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* NOTE:
|
* NOTE:
|
||||||
|
@ -112,14 +112,14 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
* without too many special cases.
|
* without too many special cases.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
qint64 lvSize = getTotalLE(lvpath);
|
qint64 lvSize = getTotalLE(lvPath);
|
||||||
qint64 startSector = mappedSector(lvpath, 0);
|
qint64 startSector = mappedSector(lvPath, 0);
|
||||||
qint64 endSector = startSector + lvSize - 1;
|
qint64 endSector = startSector + lvSize - 1;
|
||||||
|
|
||||||
FileSystem::Type type = FileSystem::detectFileSystem(lvpath);
|
FileSystem::Type type = FileSystem::detectFileSystem(lvPath);
|
||||||
FileSystem* fs = FileSystemFactory::create(type, 0, lvSize - 1);
|
FileSystem* fs = FileSystemFactory::create(type, 0, lvSize - 1);
|
||||||
|
|
||||||
bool mounted = isMounted(lvpath);
|
bool mounted = isMounted(lvPath);
|
||||||
QString mountPoint = QString();
|
QString mountPoint = QString();
|
||||||
|
|
||||||
KMountPoint::List mountPointList = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName);
|
KMountPoint::List mountPointList = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName);
|
||||||
|
@ -130,13 +130,13 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
if (type == FileSystem::Luks) {
|
if (type == FileSystem::Luks) {
|
||||||
r |= PartitionRole::Luks;
|
r |= PartitionRole::Luks;
|
||||||
FS::luks* luksFs = static_cast<FS::luks*>(fs);
|
FS::luks* luksFs = static_cast<FS::luks*>(fs);
|
||||||
QString mapperNode = FS::luks::mapperName(lvpath);
|
QString mapperNode = FS::luks::mapperName(lvPath);
|
||||||
bool isCryptOpen = !mapperNode.isEmpty();
|
bool isCryptOpen = !mapperNode.isEmpty();
|
||||||
luksFs->setCryptOpen(isCryptOpen);
|
luksFs->setCryptOpen(isCryptOpen);
|
||||||
luksFs->setLogicalSectorSize(logicalSize());
|
luksFs->setLogicalSectorSize(logicalSize());
|
||||||
|
|
||||||
if (isCryptOpen) {
|
if (isCryptOpen) {
|
||||||
luksFs->loadInnerFileSystem(lvpath, mapperNode);
|
luksFs->loadInnerFileSystem(lvPath, mapperNode);
|
||||||
mountPoint = mountPointList.findByDevice(mapperNode) ?
|
mountPoint = mountPointList.findByDevice(mapperNode) ?
|
||||||
mountPointList.findByDevice(mapperNode)->mountPoint() :
|
mountPointList.findByDevice(mapperNode)->mountPoint() :
|
||||||
QString();
|
QString();
|
||||||
|
@ -144,15 +144,15 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
||||||
if (freeSpaceInfo.isValid() && mountPoint != QString())
|
if (freeSpaceInfo.isValid() && mountPoint != QString())
|
||||||
luksFs->setSectorsUsed((freeSpaceInfo.used() + luksFs->getPayloadOffset(lvpath)) / logicalSize());
|
luksFs->setSectorsUsed((freeSpaceInfo.used() + luksFs->getPayloadOffset(lvPath)) / logicalSize());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mounted = false;
|
mounted = false;
|
||||||
}
|
}
|
||||||
luksFs->setMounted(mounted);
|
luksFs->setMounted(mounted);
|
||||||
} else {
|
} else {
|
||||||
mountPoint = mountPointList.findByDevice(lvpath) ?
|
mountPoint = mountPointList.findByDevice(lvPath) ?
|
||||||
mountPointList.findByDevice(lvpath)->mountPoint() :
|
mountPointList.findByDevice(lvPath)->mountPoint() :
|
||||||
QString();
|
QString();
|
||||||
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint);
|
||||||
|
|
||||||
|
@ -161,16 +161,16 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) {
|
if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) {
|
||||||
fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize());
|
fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize());
|
||||||
} else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) {
|
} else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) {
|
||||||
fs->setSectorsUsed(fs->readUsedCapacity(lvpath) / logicalSize());
|
fs->setSectorsUsed(fs->readUsedCapacity(lvPath) / logicalSize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs->supportGetLabel() != FileSystem::cmdSupportNone) {
|
if (fs->supportGetLabel() != FileSystem::cmdSupportNone) {
|
||||||
fs->setLabel(fs->readLabel(lvpath));
|
fs->setLabel(fs->readLabel(lvPath));
|
||||||
}
|
}
|
||||||
if (fs->supportGetUUID() != FileSystem::cmdSupportNone)
|
if (fs->supportGetUUID() != FileSystem::cmdSupportNone)
|
||||||
fs->setUUID(fs->readUUID(lvpath));
|
fs->setUUID(fs->readUUID(lvPath));
|
||||||
|
|
||||||
Partition* part = new Partition(pTable,
|
Partition* part = new Partition(pTable,
|
||||||
*this,
|
*this,
|
||||||
|
@ -178,7 +178,7 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
fs,
|
fs,
|
||||||
startSector,
|
startSector,
|
||||||
endSector,
|
endSector,
|
||||||
lvpath,
|
lvPath,
|
||||||
PartitionTable::Flag::FlagNone,
|
PartitionTable::Flag::FlagNone,
|
||||||
mountPoint,
|
mountPoint,
|
||||||
mounted);
|
mounted);
|
||||||
|
@ -191,17 +191,17 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl
|
||||||
QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
QList<LvmDevice*> LvmDevice::scanSystemLVM()
|
||||||
{
|
{
|
||||||
QList<LvmDevice*> lvmList;
|
QList<LvmDevice*> lvmList;
|
||||||
for (const auto &vgname : getVGs()) {
|
for (const auto &vgName : getVGs()) {
|
||||||
lvmList.append(new LvmDevice(vgname));
|
lvmList.append(new LvmDevice(vgName));
|
||||||
}
|
}
|
||||||
return lvmList;
|
return lvmList;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 = partitionNodes();
|
QList<QString> lvpathList = partitionNodes();
|
||||||
qint32 devIndex = lvpathList.indexOf(lvpath);
|
qint32 devIndex = lvpathList.indexOf(lvPath);
|
||||||
|
|
||||||
if (devIndex) {
|
if (devIndex) {
|
||||||
for (int i = 0; i < devIndex; i++) {
|
for (int i = 0; i < devIndex; i++) {
|
||||||
|
@ -232,18 +232,18 @@ const QStringList LvmDevice::getVGs()
|
||||||
QStringList vgList;
|
QStringList vgList;
|
||||||
QString output = getField(QStringLiteral("vg_name"));
|
QString output = getField(QStringLiteral("vg_name"));
|
||||||
if (!output.isEmpty()) {
|
if (!output.isEmpty()) {
|
||||||
const QStringList vgnameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
const QStringList vgNameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||||
for (const auto &vgname : vgnameList) {
|
for (const auto &vgName : vgNameList) {
|
||||||
vgList.append(vgname.trimmed());
|
vgList.append(vgName.trimmed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vgList;
|
return vgList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const 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);
|
||||||
|
|
||||||
if (cmdOutput.size()) {
|
if (cmdOutput.size()) {
|
||||||
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||||
|
@ -254,10 +254,10 @@ const QStringList LvmDevice::getPVs(const QString& vgname)
|
||||||
return devPathList;
|
return devPathList;
|
||||||
}
|
}
|
||||||
|
|
||||||
const 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);
|
||||||
|
|
||||||
if (cmdOutput.size()) {
|
if (cmdOutput.size()) {
|
||||||
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts);
|
||||||
|
@ -268,32 +268,32 @@ const QStringList LvmDevice::getLVs(const QString& vgname)
|
||||||
return lvPathList;
|
return lvPathList;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LvmDevice::getPeSize(const QString& vgname)
|
qint64 LvmDevice::getPeSize(const QString& vgName)
|
||||||
{
|
{
|
||||||
QString val = getField(QStringLiteral("vg_extent_size"), vgname);
|
QString val = getField(QStringLiteral("vg_extent_size"), vgName);
|
||||||
return val.isEmpty() ? -1 : val.toInt();
|
return val.isEmpty() ? -1 : val.toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LvmDevice::getTotalPE(const QString& vgname)
|
qint64 LvmDevice::getTotalPE(const QString& vgName)
|
||||||
{
|
{
|
||||||
QString val = getField(QStringLiteral("vg_extent_count"), vgname);
|
QString val = getField(QStringLiteral("vg_extent_count"), vgName);
|
||||||
return val.isEmpty() ? -1 : val.toInt();
|
return val.isEmpty() ? -1 : val.toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LvmDevice::getAllocatedPE(const QString& vgname)
|
qint64 LvmDevice::getAllocatedPE(const QString& vgName)
|
||||||
{
|
{
|
||||||
return getTotalPE(vgname) - getFreePE(vgname);
|
return getTotalPE(vgName) - getFreePE(vgName);
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LvmDevice::getFreePE(const QString& vgname)
|
qint64 LvmDevice::getFreePE(const QString& vgName)
|
||||||
{
|
{
|
||||||
QString val = getField(QStringLiteral("vg_free_count"), vgname);
|
QString val = getField(QStringLiteral("vg_free_count"), vgName);
|
||||||
return val.isEmpty() ? -1 : val.toInt();
|
return val.isEmpty() ? -1 : val.toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString LvmDevice::getUUID(const QString& vgname)
|
QString LvmDevice::getUUID(const QString& vgName)
|
||||||
{
|
{
|
||||||
QString val = getField(QStringLiteral("vg_uuid"), vgname);
|
QString val = getField(QStringLiteral("vg_uuid"), vgName);
|
||||||
return val.isEmpty() ? QStringLiteral("---") : val;
|
return val.isEmpty() ? QStringLiteral("---") : val;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -301,11 +301,11 @@ QString LvmDevice::getUUID(const QString& vgname)
|
||||||
/** Get LVM vgs command output with field name
|
/** Get LVM vgs command output with field name
|
||||||
*
|
*
|
||||||
* @param fieldName LVM field name
|
* @param fieldName LVM field name
|
||||||
* @param vgname the name of LVM Volume Group
|
* @param vgName the name of LVM Volume Group
|
||||||
* @return raw output of command output, usully with many spaces within the returned string
|
* @return raw output of command output, usully with many spaces within the returned string
|
||||||
* */
|
* */
|
||||||
|
|
||||||
QString LvmDevice::getField(const QString& fieldName, const QString& vgname)
|
QString LvmDevice::getField(const QString& fieldName, const QString& vgName)
|
||||||
{
|
{
|
||||||
QStringList args = { QStringLiteral("vgs"),
|
QStringList args = { QStringLiteral("vgs"),
|
||||||
QStringLiteral("--foreign"),
|
QStringLiteral("--foreign"),
|
||||||
|
@ -316,8 +316,8 @@ QString LvmDevice::getField(const QString& fieldName, const QString& vgname)
|
||||||
QStringLiteral("--nosuffix"),
|
QStringLiteral("--nosuffix"),
|
||||||
QStringLiteral("--options"),
|
QStringLiteral("--options"),
|
||||||
fieldName };
|
fieldName };
|
||||||
if (!vgname.isEmpty()) {
|
if (!vgName.isEmpty()) {
|
||||||
args << vgname;
|
args << vgName;
|
||||||
}
|
}
|
||||||
ExternalCommand cmd(QStringLiteral("lvm"), args);
|
ExternalCommand cmd(QStringLiteral("lvm"), args);
|
||||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||||
|
@ -326,11 +326,11 @@ QString LvmDevice::getField(const QString& fieldName, const QString& vgname)
|
||||||
return QString();
|
return QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 LvmDevice::getTotalLE(const QString& lvpath)
|
qint64 LvmDevice::getTotalLE(const QString& lvPath)
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(QStringLiteral("lvm"),
|
ExternalCommand cmd(QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("lvdisplay"),
|
{ QStringLiteral("lvdisplay"),
|
||||||
lvpath});
|
lvPath});
|
||||||
|
|
||||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||||
QRegularExpression re(QStringLiteral("Current LE\\h+(\\d+)"));
|
QRegularExpression re(QStringLiteral("Current LE\\h+(\\d+)"));
|
||||||
|
@ -342,39 +342,39 @@ qint64 LvmDevice::getTotalLE(const QString& lvpath)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::removeLV(Report& report, LvmDevice& dev, Partition& part)
|
bool LvmDevice::removeLV(Report& report, LvmDevice& d, Partition& p)
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("lvremove"),
|
{ QStringLiteral("lvremove"),
|
||||||
QStringLiteral("--yes"),
|
QStringLiteral("--yes"),
|
||||||
part.partitionPath()});
|
p.partitionPath()});
|
||||||
|
|
||||||
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
if (cmd.run(-1) && cmd.exitCode() == 0) {
|
||||||
//TODO: remove Partition from PartitionTable and delete from memory ??
|
//TODO: remove Partition from PartitionTable and delete from memory ??
|
||||||
dev.partitionTable()->remove(&part);
|
d.partitionTable()->remove(&p);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname)
|
bool LvmDevice::createLV(Report& report, LvmDevice& d, Partition& p, const QString& lvName)
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("lvcreate"),
|
{ QStringLiteral("lvcreate"),
|
||||||
QStringLiteral("--yes"),
|
QStringLiteral("--yes"),
|
||||||
QStringLiteral("--extents"),
|
QStringLiteral("--extents"),
|
||||||
QString::number(part.length()),
|
QString::number(p.length()),
|
||||||
QStringLiteral("--name"),
|
QStringLiteral("--name"),
|
||||||
lvname,
|
lvName,
|
||||||
dev.name()});
|
d.name()});
|
||||||
|
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::createLVSnapshot(Report& report, Partition& lvpart, const QString& name, const qint64 extents)
|
bool LvmDevice::createLVSnapshot(Report& report, Partition& p, const QString& name, const qint64 extents)
|
||||||
{
|
{
|
||||||
QString numExtents = (extents > 0) ? QString::number(extents) :
|
QString numExtents = (extents > 0) ? QString::number(extents) :
|
||||||
QString::number(lvpart.length());
|
QString::number(p.length());
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("lvcreate"),
|
{ QStringLiteral("lvcreate"),
|
||||||
QStringLiteral("--yes"),
|
QStringLiteral("--yes"),
|
||||||
|
@ -383,11 +383,11 @@ bool LvmDevice::createLVSnapshot(Report& report, Partition& lvpart, const QStrin
|
||||||
QStringLiteral("--snapshot"),
|
QStringLiteral("--snapshot"),
|
||||||
QStringLiteral("--name"),
|
QStringLiteral("--name"),
|
||||||
name,
|
name,
|
||||||
lvpart.partitionPath() });
|
p.partitionPath() });
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::resizeLV(Report& report, Partition& part)
|
bool LvmDevice::resizeLV(Report& report, Partition& p)
|
||||||
{
|
{
|
||||||
//TODO: thorough tests and add warning that it could currupt the user data.
|
//TODO: thorough tests and add warning that it could currupt the user data.
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
|
@ -395,29 +395,29 @@ bool LvmDevice::resizeLV(Report& report, Partition& part)
|
||||||
QStringLiteral("--force"), // this command could corrupt user data
|
QStringLiteral("--force"), // this command could corrupt user data
|
||||||
QStringLiteral("--yes"),
|
QStringLiteral("--yes"),
|
||||||
QStringLiteral("--extents"),
|
QStringLiteral("--extents"),
|
||||||
QString::number(part.length()),
|
QString::number(p.length()),
|
||||||
part.partitionPath()});
|
p.partitionPath()});
|
||||||
|
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::removePV(Report& report, LvmDevice& dev, const QString& pvPath)
|
bool LvmDevice::removePV(Report& report, LvmDevice& d, const QString& pvPath)
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("vgreduce"),
|
{ QStringLiteral("vgreduce"),
|
||||||
//QStringLiteral("--yes"), // potentially corrupt user data
|
//QStringLiteral("--yes"), // potentially corrupt user data
|
||||||
dev.name(),
|
d.name(),
|
||||||
pvPath});
|
pvPath});
|
||||||
|
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::insertPV(Report& report, LvmDevice& dev, const QString& pvPath)
|
bool LvmDevice::insertPV(Report& report, LvmDevice& d, const QString& pvPath)
|
||||||
{
|
{
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("vgextend"),
|
{ QStringLiteral("vgextend"),
|
||||||
//QStringLiteral("--yes"), // potentially corrupt user data
|
//QStringLiteral("--yes"), // potentially corrupt user data
|
||||||
dev.name(),
|
d.name(),
|
||||||
pvPath});
|
pvPath});
|
||||||
|
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
|
@ -442,60 +442,60 @@ bool LvmDevice::movePV(Report& report, const QString& pvPath, const QStringList&
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::createVG(Report& report, const QString vgname, const QStringList pvlist, const qint32 peSize)
|
bool LvmDevice::createVG(Report& report, const QString vgName, const QStringList pvList, const qint32 peSize)
|
||||||
{
|
{
|
||||||
QStringList args = QStringList();
|
QStringList args = QStringList();
|
||||||
args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize);
|
args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize);
|
||||||
args << vgname;
|
args << vgName;
|
||||||
for (const auto &pvnode : pvlist) {
|
for (const auto &pvNode : pvList) {
|
||||||
args << pvnode.trimmed();
|
args << pvNode.trimmed();
|
||||||
}
|
}
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
|
ExternalCommand cmd(report, QStringLiteral("lvm"), args);
|
||||||
|
|
||||||
return (cmd.run(-1) && cmd.exitCode() == 0);
|
return (cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::removeVG(Report& report, LvmDevice& dev)
|
bool LvmDevice::removeVG(Report& report, LvmDevice& d)
|
||||||
{
|
{
|
||||||
bool deactivated = deactivateVG(report, dev);
|
bool deactivated = deactivateVG(report, d);
|
||||||
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
ExternalCommand cmd(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("vgremove"),
|
{ QStringLiteral("vgremove"),
|
||||||
dev.name() });
|
d.name() });
|
||||||
return (deactivated && cmd.run(-1) && cmd.exitCode() == 0);
|
return (deactivated && cmd.run(-1) && cmd.exitCode() == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::deactivateVG(Report& report, const LvmDevice& dev)
|
bool LvmDevice::deactivateVG(Report& report, const LvmDevice& d)
|
||||||
{
|
{
|
||||||
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("vgchange"),
|
{ QStringLiteral("vgchange"),
|
||||||
QStringLiteral("--activate"), QStringLiteral("n"),
|
QStringLiteral("--activate"), QStringLiteral("n"),
|
||||||
dev.name() });
|
d.name() });
|
||||||
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::deactivateLV(Report& report, const Partition& part)
|
bool LvmDevice::deactivateLV(Report& report, const Partition& p)
|
||||||
{
|
{
|
||||||
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("lvchange"),
|
{ QStringLiteral("lvchange"),
|
||||||
QStringLiteral("--activate"), QStringLiteral("n"),
|
QStringLiteral("--activate"), QStringLiteral("n"),
|
||||||
part.partitionPath() });
|
p.partitionPath() });
|
||||||
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::activateVG(Report& report, const LvmDevice& dev)
|
bool LvmDevice::activateVG(Report& report, const LvmDevice& d)
|
||||||
{
|
{
|
||||||
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("vgchange"),
|
{ QStringLiteral("vgchange"),
|
||||||
QStringLiteral("--activate"), QStringLiteral("y"),
|
QStringLiteral("--activate"), QStringLiteral("y"),
|
||||||
dev.name() });
|
d.name() });
|
||||||
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LvmDevice::activateLV(Report& report, Partition& part)
|
bool LvmDevice::activateLV(Report& report, Partition& p)
|
||||||
{
|
{
|
||||||
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
ExternalCommand deactivate(report, QStringLiteral("lvm"),
|
||||||
{ QStringLiteral("lvchange"),
|
{ QStringLiteral("lvchange"),
|
||||||
QStringLiteral("--activate"), QStringLiteral("y"),
|
QStringLiteral("--activate"), QStringLiteral("y"),
|
||||||
part.partitionPath() });
|
p.partitionPath() });
|
||||||
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
return deactivate.run(-1) && deactivate.exitCode() == 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice
|
||||||
Q_DISABLE_COPY(LvmDevice)
|
Q_DISABLE_COPY(LvmDevice)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LvmDevice(const QString& name, const QString& iconname = QString());
|
LvmDevice(const QString& name, const QString& iconName = QString());
|
||||||
~LvmDevice();
|
~LvmDevice();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -62,33 +62,33 @@ public:
|
||||||
static QList<LvmDevice*> scanSystemLVM();
|
static QList<LvmDevice*> scanSystemLVM();
|
||||||
|
|
||||||
static const QStringList getVGs();
|
static const QStringList getVGs();
|
||||||
static const QStringList getPVs(const QString& vgname);
|
static const QStringList getPVs(const QString& vgName);
|
||||||
static const QStringList getLVs(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);
|
||||||
static qint64 getFreePE(const QString& vgname);
|
static qint64 getFreePE(const QString& vgName);
|
||||||
static QString getUUID(const QString& vgname);
|
static QString getUUID(const QString& vgName);
|
||||||
static QString getField(const QString& fieldName, const QString& vgname = QString());
|
static QString getField(const QString& fieldName, const QString& vgName = QString());
|
||||||
|
|
||||||
static qint64 getTotalLE(const QString& lvpath);
|
static qint64 getTotalLE(const QString& lvPath);
|
||||||
|
|
||||||
static bool removeLV(Report& report, LvmDevice& dev, Partition& part);
|
static bool removeLV(Report& report, LvmDevice& d, Partition& p);
|
||||||
static bool createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname);
|
static bool createLV(Report& report, LvmDevice& d, Partition& p, const QString& lvName);
|
||||||
static bool createLVSnapshot(Report& report, Partition& lvpart, const QString& name, const qint64 extents = 0);
|
static bool createLVSnapshot(Report& report, Partition& p, const QString& name, const qint64 extents = 0);
|
||||||
static bool resizeLV(Report& report, Partition& part);
|
static bool resizeLV(Report& report, Partition& p);
|
||||||
static bool deactivateLV(Report& report, const Partition& part);
|
static bool deactivateLV(Report& report, const Partition& p);
|
||||||
static bool activateLV(Report& report, Partition& part);
|
static bool activateLV(Report& report, Partition& p);
|
||||||
|
|
||||||
static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath);
|
static bool removePV(Report& report, LvmDevice& d, const QString& pvPath);
|
||||||
static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath);
|
static bool insertPV(Report& report, LvmDevice& d, const QString& pvPath);
|
||||||
static bool movePV(Report& report, const QString& pvPath, const QStringList& destinations = QStringList());
|
static bool movePV(Report& report, const QString& pvPath, const QStringList& destinations = QStringList());
|
||||||
|
|
||||||
static bool removeVG(Report& report, LvmDevice& dev);
|
static bool removeVG(Report& report, LvmDevice& d);
|
||||||
static bool createVG(Report& report, const QString vgname, const QStringList pvlist, const qint32 peSize = 4); // peSize in megabytes
|
static bool createVG(Report& report, const QString vgName, const QStringList pvList, const qint32 peSize = 4); // peSize in megabytes
|
||||||
static bool deactivateVG(Report& report, const LvmDevice& dev);
|
static bool deactivateVG(Report& report, const LvmDevice& d);
|
||||||
static bool activateVG(Report& report, const LvmDevice& dev);
|
static bool activateVG(Report& report, const LvmDevice& d);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ protected:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Partition* scanPartition(const QString& lvPath, 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:
|
||||||
qint64 peSize() const {
|
qint64 peSize() const {
|
||||||
|
|
|
@ -39,13 +39,13 @@
|
||||||
/** Creates a new PartitionTable object with type MSDOS
|
/** Creates a new PartitionTable object with type MSDOS
|
||||||
@param type name of the PartitionTable type (e.g. "msdos" or "gpt")
|
@param type name of the PartitionTable type (e.g. "msdos" or "gpt")
|
||||||
*/
|
*/
|
||||||
PartitionTable::PartitionTable(TableType type, qint64 first_usable, qint64 last_usable) :
|
PartitionTable::PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable) :
|
||||||
PartitionNode(),
|
PartitionNode(),
|
||||||
m_Children(),
|
m_Children(),
|
||||||
m_MaxPrimaries(maxPrimariesForTableType(type)),
|
m_MaxPrimaries(maxPrimariesForTableType(type)),
|
||||||
m_Type(type),
|
m_Type(type),
|
||||||
m_FirstUsable(first_usable),
|
m_FirstUsable(firstUsable),
|
||||||
m_LastUsable(last_usable)
|
m_LastUsable(lastUsable)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,7 +95,7 @@ public:
|
||||||
Q_FLAG(Flag)
|
Q_FLAG(Flag)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PartitionTable(TableType type, qint64 first_usable, qint64 last_usable);
|
PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable);
|
||||||
~PartitionTable();
|
~PartitionTable();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -20,12 +20,12 @@
|
||||||
/** Constructs a Volume Manager 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,
|
||||||
const qint32 logicalSize,
|
const qint32 logicalSize,
|
||||||
const qint64 totalLogical,
|
const qint64 totalLogical,
|
||||||
const QString& iconname,
|
const QString& iconName,
|
||||||
Device::Type type)
|
Device::Type type)
|
||||||
: Device(name, devicenode, logicalSize, totalLogical, iconname, type)
|
: Device(name, deviceNode, logicalSize, totalLogical, iconName, type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ 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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return list of physical device or partitions that makes up volumeManagerDevice.
|
* @return list of physical device or partitions that makes up volumeManagerDevice.
|
||||||
|
|
|
@ -24,14 +24,15 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
/** Creates a new CreateVolumeGroupJob
|
/** Creates a new CreateVolumeGroupJob
|
||||||
@param vgname LVM Volume Group name
|
* @param vgName LVM Volume Group name
|
||||||
@param pvlist List of LVM Physical Volumes
|
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
||||||
|
* @param peSize LVM Physical Extent size in MiB
|
||||||
*/
|
*/
|
||||||
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize) :
|
CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgName, const QStringList& pvList, const qint32 peSize) :
|
||||||
Job(),
|
Job(),
|
||||||
m_vgName(vgname),
|
m_vgName(vgName),
|
||||||
m_pvList(pvlist),
|
m_pvList(pvList),
|
||||||
m_PESize(pesize)
|
m_PESize(peSize)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ class QString;
|
||||||
class CreateVolumeGroupJob : public Job
|
class CreateVolumeGroupJob : public Job
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize);
|
CreateVolumeGroupJob(const QString& vgName, const QStringList& pvList, const qint32 peSize);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool run(Report& parent) override;
|
bool run(Report& parent) override;
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
|
|
||||||
/** Creates a new DeactivateLogicalVolumeJob
|
/** Creates a new DeactivateLogicalVolumeJob
|
||||||
*/
|
*/
|
||||||
DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& dev, const QStringList lvPaths) :
|
DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& d, const QStringList lvPaths) :
|
||||||
Job(),
|
Job(),
|
||||||
m_Device(dev),
|
m_Device(d),
|
||||||
m_LVList(lvPaths)
|
m_LVList(lvPaths)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
|
|
||||||
/** Deactivate LVM Volume Group
|
/** Deactivate LVM Volume Group
|
||||||
*/
|
*/
|
||||||
DeactivateVolumeGroupJob::DeactivateVolumeGroupJob(VolumeManagerDevice& dev) :
|
DeactivateVolumeGroupJob::DeactivateVolumeGroupJob(VolumeManagerDevice& d) :
|
||||||
Job(),
|
Job(),
|
||||||
m_Device(dev)
|
m_Device(d)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,11 +24,12 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
/** Creates a new MovePhysicalVolumeJob
|
/** Creates a new MovePhysicalVolumeJob
|
||||||
|
* @param d Device representing LVM Volume Group
|
||||||
*/
|
*/
|
||||||
MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& dev, const QStringList partlist) :
|
MovePhysicalVolumeJob::MovePhysicalVolumeJob(LvmDevice& d, const QStringList partList) :
|
||||||
Job(),
|
Job(),
|
||||||
m_Device(dev),
|
m_Device(d),
|
||||||
m_PartList(partlist)
|
m_PartList(partList)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
|
|
||||||
/** Creates a new RemoveVolumeGroupJob
|
/** Creates a new RemoveVolumeGroupJob
|
||||||
*/
|
*/
|
||||||
RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& dev) :
|
RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& d) :
|
||||||
Job(),
|
Job(),
|
||||||
m_Device(dev)
|
m_Device(d)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,11 +27,14 @@
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
|
|
||||||
/** Creates a new CreateVolumeGroupOperation.
|
/** Creates a new CreateVolumeGroupOperation.
|
||||||
|
* @param vgName LVM Volume Group name
|
||||||
|
* @param pvList List of LVM Physical Volumes used to create Volume Group
|
||||||
|
* @param peSize LVM Physical Extent size in MiB
|
||||||
*/
|
*/
|
||||||
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist, const qint32 pesize) :
|
CreateVolumeGroupOperation::CreateVolumeGroupOperation(const QString& vgName, const QStringList& pvList, const qint32 peSize) :
|
||||||
Operation(),
|
Operation(),
|
||||||
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgname, pvlist, pesize)),
|
m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgName, pvList, peSize)),
|
||||||
m_PVList(pvlist)
|
m_PVList(pvList)
|
||||||
{
|
{
|
||||||
addJob(createVolumeGroupJob());
|
addJob(createVolumeGroupJob());
|
||||||
}
|
}
|
||||||
|
@ -41,9 +44,8 @@ QString CreateVolumeGroupOperation::description() const
|
||||||
return xi18nc("@info/plain", "Create a new LVM volume group.");
|
return xi18nc("@info/plain", "Create a new LVM volume group.");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateVolumeGroupOperation::targets(const Partition& part) const
|
bool CreateVolumeGroupOperation::targets(const Partition&) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(part)
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,9 +56,9 @@ void CreateVolumeGroupOperation::preview()
|
||||||
|
|
||||||
void CreateVolumeGroupOperation::undo()
|
void CreateVolumeGroupOperation::undo()
|
||||||
{
|
{
|
||||||
for (const auto &pvpath : PVList()) {
|
for (const auto &pvPath : PVList()) {
|
||||||
if (LvmDevice::s_DirtyPVs.contains(pvpath)) {
|
if (LvmDevice::s_DirtyPVs.contains(pvPath)) {
|
||||||
LvmDevice::s_DirtyPVs.removeAll(pvpath);
|
LvmDevice::s_DirtyPVs.removeAll(pvPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ class LIBKPMCORE_EXPORT CreateVolumeGroupOperation : public Operation
|
||||||
friend class OperationStack;
|
friend class OperationStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist, const qint32 pesize = 4);
|
CreateVolumeGroupOperation(const QString& vgName, const QStringList& pvList, const qint32 peSize = 4);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString iconName() const override {
|
QString iconName() const override {
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
|
|
||||||
/** Creates a new RemoveVolumeGroupOperation.
|
/** Creates a new RemoveVolumeGroupOperation.
|
||||||
*/
|
*/
|
||||||
DeactivateVolumeGroupOperation::DeactivateVolumeGroupOperation(VolumeManagerDevice& dev) :
|
DeactivateVolumeGroupOperation::DeactivateVolumeGroupOperation(VolumeManagerDevice& d) :
|
||||||
Operation(),
|
Operation(),
|
||||||
m_DeactivateVolumeGroupJob(new DeactivateVolumeGroupJob(dev)),
|
m_DeactivateVolumeGroupJob(new DeactivateVolumeGroupJob(d)),
|
||||||
m_DeactivateLogicalVolumeJob(new DeactivateLogicalVolumeJob(dev)),
|
m_DeactivateLogicalVolumeJob(new DeactivateLogicalVolumeJob(d)),
|
||||||
m_Device(dev)
|
m_Device(d)
|
||||||
{
|
{
|
||||||
addJob(deactivateLogicalVolumeJob());
|
addJob(deactivateLogicalVolumeJob());
|
||||||
addJob(deactivateVolumeGroupJob());
|
addJob(deactivateVolumeGroupJob());
|
||||||
|
|
|
@ -38,7 +38,7 @@ class LIBKPMCORE_EXPORT DeactivateVolumeGroupOperation : public Operation
|
||||||
friend class OperationStack;
|
friend class OperationStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeactivateVolumeGroupOperation(VolumeManagerDevice& dev);
|
DeactivateVolumeGroupOperation(VolumeManagerDevice& d);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString iconName() const override {
|
QString iconName() const override {
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
|
|
||||||
/** Creates a new RemoveVolumeGroupOperation.
|
/** Creates a new RemoveVolumeGroupOperation.
|
||||||
*/
|
*/
|
||||||
RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& dev) :
|
RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& d) :
|
||||||
Operation(),
|
Operation(),
|
||||||
m_RemoveVolumeGroupJob(new RemoveVolumeGroupJob(dev)),
|
m_RemoveVolumeGroupJob(new RemoveVolumeGroupJob(d)),
|
||||||
m_Device(dev)
|
m_Device(d)
|
||||||
{
|
{
|
||||||
addJob(removeVolumeGroupJob());
|
addJob(removeVolumeGroupJob());
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ class LIBKPMCORE_EXPORT RemoveVolumeGroupOperation : public Operation
|
||||||
friend class OperationStack;
|
friend class OperationStack;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RemoveVolumeGroupOperation(VolumeManagerDevice& dev);
|
RemoveVolumeGroupOperation(VolumeManagerDevice& d);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QString iconName() const override {
|
QString iconName() const override {
|
||||||
|
|
|
@ -30,22 +30,22 @@
|
||||||
|
|
||||||
/** Creates a new ResizeVolumeGroupOperation.
|
/** Creates a new ResizeVolumeGroupOperation.
|
||||||
@param d the Device to create the new PartitionTable on
|
@param d the Device to create the new PartitionTable on
|
||||||
@param t the type for the new PartitionTable
|
@param partlist list of LVM Physical Volumes that should be in LVM Volume Group
|
||||||
*/
|
*/
|
||||||
ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& dev, const QStringList partlist) :
|
ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& d, const QStringList partlist) :
|
||||||
Operation(),
|
Operation(),
|
||||||
m_Device(dev),
|
m_Device(d),
|
||||||
m_TargetList(partlist),
|
m_TargetList(partlist),
|
||||||
m_CurrentList(LvmDevice::getPVs(dev.name())),
|
m_CurrentList(LvmDevice::getPVs(d.name())),
|
||||||
m_GrowVolumeGroupJob(nullptr),
|
m_GrowVolumeGroupJob(nullptr),
|
||||||
m_ShrinkVolumeGroupJob(nullptr),
|
m_ShrinkVolumeGroupJob(nullptr),
|
||||||
m_MovePhysicalVolumeJob(nullptr)
|
m_MovePhysicalVolumeJob(nullptr)
|
||||||
{
|
{
|
||||||
const QStringList clist = currentList();
|
const QStringList curList = currentList();
|
||||||
m_TargetSize = FS::lvm2_pv::getPVSize(targetList());
|
m_TargetSize = FS::lvm2_pv::getPVSize(targetList());
|
||||||
m_CurrentSize = FS::lvm2_pv::getPVSize(currentList());
|
m_CurrentSize = FS::lvm2_pv::getPVSize(currentList());
|
||||||
|
|
||||||
QStringList toRemoveList = clist;
|
QStringList toRemoveList = curList;
|
||||||
for (QString path : partlist) {
|
for (QString path : partlist) {
|
||||||
if (toRemoveList.contains(path)) {
|
if (toRemoveList.contains(path)) {
|
||||||
toRemoveList.removeAll(path);
|
toRemoveList.removeAll(path);
|
||||||
|
@ -53,28 +53,28 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& dev, const QSt
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList toInsertList = partlist;
|
QStringList toInsertList = partlist;
|
||||||
for (QString path : clist) {
|
for (QString path : curList) {
|
||||||
if (toInsertList.contains(path)) {
|
if (toInsertList.contains(path)) {
|
||||||
toInsertList.removeAll(path);
|
toInsertList.removeAll(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 freePE = FS::lvm2_pv::getFreePE(clist) - FS::lvm2_pv::getFreePE(toRemoveList);
|
qint64 freePE = FS::lvm2_pv::getFreePE(curList) - FS::lvm2_pv::getFreePE(toRemoveList);
|
||||||
qint64 movePE = FS::lvm2_pv::getAllocatedPE(toRemoveList);
|
qint64 movePE = FS::lvm2_pv::getAllocatedPE(toRemoveList);
|
||||||
qint64 growPE = FS::lvm2_pv::getPVSize(toInsertList) / LvmDevice::getPeSize(dev.name());
|
qint64 growPE = FS::lvm2_pv::getPVSize(toInsertList) / LvmDevice::getPeSize(d.name());
|
||||||
|
|
||||||
if ( movePE > (freePE + growPE)) {
|
if ( movePE > (freePE + growPE)) {
|
||||||
// *ABORT* can't move
|
// *ABORT* can't move
|
||||||
} else if (partlist == clist) {
|
} else if (partlist == curList) {
|
||||||
// *DO NOTHING*
|
// *DO NOTHING*
|
||||||
} else {
|
} else {
|
||||||
if (!toInsertList.isEmpty()) {
|
if (!toInsertList.isEmpty()) {
|
||||||
m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(dev, toInsertList, ResizeVolumeGroupJob::Grow);
|
m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Grow);
|
||||||
addJob(growVolumeGroupJob());
|
addJob(growVolumeGroupJob());
|
||||||
}
|
}
|
||||||
if (!toRemoveList.isEmpty()) {
|
if (!toRemoveList.isEmpty()) {
|
||||||
m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(dev, toRemoveList);
|
m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(d, toRemoveList);
|
||||||
m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(dev, toRemoveList, ResizeVolumeGroupJob::Shrink);
|
m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Shrink);
|
||||||
addJob(movePhysicalVolumeJob());
|
addJob(movePhysicalVolumeJob());
|
||||||
addJob(shrinkvolumegroupjob());
|
addJob(shrinkvolumegroupjob());
|
||||||
}
|
}
|
||||||
|
@ -94,10 +94,10 @@ bool ResizeVolumeGroupOperation::targets(const Device& d) const
|
||||||
return d == device();
|
return d == device();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ResizeVolumeGroupOperation::targets(const Partition& part) const
|
bool ResizeVolumeGroupOperation::targets(const Partition& p) const
|
||||||
{
|
{
|
||||||
for (QString partPath : targetList()) {
|
for (QString partPath : targetList()) {
|
||||||
if (partPath == part.partitionPath()) {
|
if (partPath == p.partitionPath()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue