diff --git a/src/core/diskdevice.cpp b/src/core/diskdevice.cpp index e1026d4..8beaf83 100644 --- a/src/core/diskdevice.cpp +++ b/src/core/diskdevice.cpp @@ -72,24 +72,24 @@ static qint32 getPhysicalSectorSize(const QString& device_node) /** Constructs a Disk Device with an empty PartitionTable. @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 numSectors the number of sectors in CHS notation @param cylinders the number of cylinders in CHS notation @param sectorSize the size of a sector in bytes */ DiskDevice::DiskDevice(const QString& name, - const QString& devicenode, + const QString& deviceNode, qint32 heads, qint32 numSectors, qint32 cylinders, qint32 sectorSize, - const QString& iconname) - : Device(name, devicenode, sectorSize, (static_cast(heads) * cylinders * numSectors), iconname, Device::Disk_Device) + const QString& iconName) + : Device(name, deviceNode, sectorSize, (static_cast(heads) * cylinders * numSectors), iconName, Device::Disk_Device) , m_Heads(heads) , m_SectorsPerTrack(numSectors) , m_Cylinders(cylinders) , m_LogicalSectorSize(sectorSize) - , m_PhysicalSectorSize(getPhysicalSectorSize(devicenode)) + , m_PhysicalSectorSize(getPhysicalSectorSize(deviceNode)) { } diff --git a/src/core/diskdevice.h b/src/core/diskdevice.h index 0ecb28e..4a87679 100644 --- a/src/core/diskdevice.h +++ b/src/core/diskdevice.h @@ -48,7 +48,7 @@ class LIBKPMCORE_EXPORT DiskDevice : public Device friend class CoreBackend; 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: qint32 heads() const { diff --git a/src/core/lvmdevice.cpp b/src/core/lvmdevice.cpp index 0797cd4..d357922 100644 --- a/src/core/lvmdevice.cpp +++ b/src/core/lvmdevice.cpp @@ -35,24 +35,24 @@ /** Constructs a representation of LVM device with functionning LV as Partitions * - * @param name Volume Group name - * @param iconname + * @param vgName Volume Group name + * @param iconName Icon representing LVM Volume group */ -LvmDevice::LvmDevice(const QString& name, const QString& iconname) - : VolumeManagerDevice(name, - (QStringLiteral("/dev/") + name), - getPeSize(name), - getTotalPE(name), - iconname, +LvmDevice::LvmDevice(const QString& vgName, const QString& iconName) + : VolumeManagerDevice(vgName, + (QStringLiteral("/dev/") + vgName), + getPeSize(vgName), + getTotalPE(vgName), + iconName, Device::LVM_Device) { m_peSize = logicalSize(); m_totalPE = totalLogical(); - m_freePE = getFreePE(name); + m_freePE = getFreePE(vgName); m_allocPE = m_totalPE - m_freePE; - m_UUID = getUUID(name); - m_PVPathList = new QStringList(getPVs(name)); - m_LVPathList = new QStringList(getLVs(name)); + m_UUID = getUUID(vgName); + m_PVPathList = new QStringList(getPVs(vgName)); + m_LVPathList = new QStringList(getLVs(vgName)); m_LVSizeMap = new QMap(); initPartitions(); @@ -96,11 +96,11 @@ const QList LvmDevice::scanPartitions(PartitionTable* pTable) const } /** - * @param lvpath - * @param pTable + * @param lvPath LVM Logical Volume path + * @param pTable Abstract partition table representing partitions of LVM Volume Group * @return sorted Partition (LV) Array */ -Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTable) const +Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTable) const { /* * NOTE: @@ -112,14 +112,14 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl * without too many special cases. */ - qint64 lvSize = getTotalLE(lvpath); - qint64 startSector = mappedSector(lvpath, 0); + qint64 lvSize = getTotalLE(lvPath); + qint64 startSector = mappedSector(lvPath, 0); 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); - bool mounted = isMounted(lvpath); + bool mounted = isMounted(lvPath); QString mountPoint = QString(); KMountPoint::List mountPointList = KMountPoint::currentMountPoints(KMountPoint::NeedRealDeviceName); @@ -130,13 +130,13 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl if (type == FileSystem::Luks) { r |= PartitionRole::Luks; FS::luks* luksFs = static_cast(fs); - QString mapperNode = FS::luks::mapperName(lvpath); + QString mapperNode = FS::luks::mapperName(lvPath); bool isCryptOpen = !mapperNode.isEmpty(); luksFs->setCryptOpen(isCryptOpen); luksFs->setLogicalSectorSize(logicalSize()); if (isCryptOpen) { - luksFs->loadInnerFileSystem(lvpath, mapperNode); + luksFs->loadInnerFileSystem(lvPath, mapperNode); mountPoint = mountPointList.findByDevice(mapperNode) ? mountPointList.findByDevice(mapperNode)->mountPoint() : QString(); @@ -144,15 +144,15 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl if (mounted) { const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint); if (freeSpaceInfo.isValid() && mountPoint != QString()) - luksFs->setSectorsUsed((freeSpaceInfo.used() + luksFs->getPayloadOffset(lvpath)) / logicalSize()); + luksFs->setSectorsUsed((freeSpaceInfo.used() + luksFs->getPayloadOffset(lvPath)) / logicalSize()); } } else { mounted = false; } luksFs->setMounted(mounted); } else { - mountPoint = mountPointList.findByDevice(lvpath) ? - mountPointList.findByDevice(lvpath)->mountPoint() : + mountPoint = mountPointList.findByDevice(lvPath) ? + mountPointList.findByDevice(lvPath)->mountPoint() : QString(); const KDiskFreeSpaceInfo freeSpaceInfo = KDiskFreeSpaceInfo::freeSpaceInfo(mountPoint); @@ -161,16 +161,16 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl if (mounted && freeSpaceInfo.isValid() && mountPoint != QString()) { fs->setSectorsUsed(freeSpaceInfo.used() / logicalSize()); } else if (fs->supportGetUsed() == FileSystem::cmdSupportFileSystem) { - fs->setSectorsUsed(fs->readUsedCapacity(lvpath) / logicalSize()); + fs->setSectorsUsed(fs->readUsedCapacity(lvPath) / logicalSize()); } } } if (fs->supportGetLabel() != FileSystem::cmdSupportNone) { - fs->setLabel(fs->readLabel(lvpath)); + fs->setLabel(fs->readLabel(lvPath)); } if (fs->supportGetUUID() != FileSystem::cmdSupportNone) - fs->setUUID(fs->readUUID(lvpath)); + fs->setUUID(fs->readUUID(lvPath)); Partition* part = new Partition(pTable, *this, @@ -178,7 +178,7 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl fs, startSector, endSector, - lvpath, + lvPath, PartitionTable::Flag::FlagNone, mountPoint, mounted); @@ -191,17 +191,17 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTabl QList LvmDevice::scanSystemLVM() { QList lvmList; - for (const auto &vgname : getVGs()) { - lvmList.append(new LvmDevice(vgname)); + for (const auto &vgName : getVGs()) { + lvmList.append(new LvmDevice(vgName)); } return lvmList; } -qint64 LvmDevice::mappedSector(const QString& lvpath, qint64 sector) const +qint64 LvmDevice::mappedSector(const QString& lvPath, qint64 sector) const { qint64 mSector = 0; QList lvpathList = partitionNodes(); - qint32 devIndex = lvpathList.indexOf(lvpath); + qint32 devIndex = lvpathList.indexOf(lvPath); if (devIndex) { for (int i = 0; i < devIndex; i++) { @@ -232,18 +232,18 @@ const QStringList LvmDevice::getVGs() QStringList vgList; QString output = getField(QStringLiteral("vg_name")); if (!output.isEmpty()) { - const QStringList vgnameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts); - for (const auto &vgname : vgnameList) { - vgList.append(vgname.trimmed()); + const QStringList vgNameList = output.split(QStringLiteral("\n"), QString::SkipEmptyParts); + for (const auto &vgName : vgNameList) { + vgList.append(vgName.trimmed()); } } return vgList; } -const QStringList LvmDevice::getPVs(const QString& vgname) +const QStringList LvmDevice::getPVs(const QString& vgName) { QStringList devPathList; - QString cmdOutput = getField(QStringLiteral("pv_name"), vgname); + QString cmdOutput = getField(QStringLiteral("pv_name"), vgName); if (cmdOutput.size()) { const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts); @@ -254,10 +254,10 @@ const QStringList LvmDevice::getPVs(const QString& vgname) return devPathList; } -const QStringList LvmDevice::getLVs(const QString& vgname) +const QStringList LvmDevice::getLVs(const QString& vgName) { QStringList lvPathList; - QString cmdOutput = getField(QStringLiteral("lv_path"), vgname); + QString cmdOutput = getField(QStringLiteral("lv_path"), vgName); if (cmdOutput.size()) { const QStringList tempPathList = cmdOutput.split(QStringLiteral("\n"), QString::SkipEmptyParts); @@ -268,32 +268,32 @@ const QStringList LvmDevice::getLVs(const QString& vgname) 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(); } -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(); } -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(); } -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; } @@ -301,11 +301,11 @@ QString LvmDevice::getUUID(const QString& vgname) /** Get LVM vgs command output with 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 * */ -QString LvmDevice::getField(const QString& fieldName, const QString& vgname) +QString LvmDevice::getField(const QString& fieldName, const QString& vgName) { QStringList args = { QStringLiteral("vgs"), QStringLiteral("--foreign"), @@ -316,8 +316,8 @@ QString LvmDevice::getField(const QString& fieldName, const QString& vgname) QStringLiteral("--nosuffix"), QStringLiteral("--options"), fieldName }; - if (!vgname.isEmpty()) { - args << vgname; + if (!vgName.isEmpty()) { + args << vgName; } ExternalCommand cmd(QStringLiteral("lvm"), args); if (cmd.run(-1) && cmd.exitCode() == 0) { @@ -326,11 +326,11 @@ QString LvmDevice::getField(const QString& fieldName, const QString& vgname) return QString(); } -qint64 LvmDevice::getTotalLE(const QString& lvpath) +qint64 LvmDevice::getTotalLE(const QString& lvPath) { ExternalCommand cmd(QStringLiteral("lvm"), { QStringLiteral("lvdisplay"), - lvpath}); + lvPath}); if (cmd.run(-1) && cmd.exitCode() == 0) { QRegularExpression re(QStringLiteral("Current LE\\h+(\\d+)")); @@ -342,39 +342,39 @@ qint64 LvmDevice::getTotalLE(const QString& lvpath) 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"), { QStringLiteral("lvremove"), QStringLiteral("--yes"), - part.partitionPath()}); + p.partitionPath()}); if (cmd.run(-1) && cmd.exitCode() == 0) { //TODO: remove Partition from PartitionTable and delete from memory ?? - dev.partitionTable()->remove(&part); + d.partitionTable()->remove(&p); return true; } 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"), { QStringLiteral("lvcreate"), QStringLiteral("--yes"), QStringLiteral("--extents"), - QString::number(part.length()), + QString::number(p.length()), QStringLiteral("--name"), - lvname, - dev.name()}); + lvName, + d.name()}); 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::number(lvpart.length()); + QString::number(p.length()); ExternalCommand cmd(report, QStringLiteral("lvm"), { QStringLiteral("lvcreate"), QStringLiteral("--yes"), @@ -383,11 +383,11 @@ bool LvmDevice::createLVSnapshot(Report& report, Partition& lvpart, const QStrin QStringLiteral("--snapshot"), QStringLiteral("--name"), name, - lvpart.partitionPath() }); + p.partitionPath() }); 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. 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("--yes"), QStringLiteral("--extents"), - QString::number(part.length()), - part.partitionPath()}); + QString::number(p.length()), + p.partitionPath()}); 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"), { QStringLiteral("vgreduce"), //QStringLiteral("--yes"), // potentially corrupt user data - dev.name(), + d.name(), pvPath}); 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"), { QStringLiteral("vgextend"), //QStringLiteral("--yes"), // potentially corrupt user data - dev.name(), + d.name(), pvPath}); 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); } -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(); args << QStringLiteral("vgcreate") << QStringLiteral("--physicalextentsize") << QString::number(peSize); - args << vgname; - for (const auto &pvnode : pvlist) { - args << pvnode.trimmed(); + args << vgName; + for (const auto &pvNode : pvList) { + args << pvNode.trimmed(); } ExternalCommand cmd(report, QStringLiteral("lvm"), args); 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"), { QStringLiteral("vgremove"), - dev.name() }); + d.name() }); 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"), { QStringLiteral("vgchange"), QStringLiteral("--activate"), QStringLiteral("n"), - dev.name() }); + d.name() }); 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"), { QStringLiteral("lvchange"), QStringLiteral("--activate"), QStringLiteral("n"), - part.partitionPath() }); + p.partitionPath() }); 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"), { QStringLiteral("vgchange"), QStringLiteral("--activate"), QStringLiteral("y"), - dev.name() }); + d.name() }); 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"), { QStringLiteral("lvchange"), QStringLiteral("--activate"), QStringLiteral("y"), - part.partitionPath() }); + p.partitionPath() }); return deactivate.run(-1) && deactivate.exitCode() == 0; } diff --git a/src/core/lvmdevice.h b/src/core/lvmdevice.h index 70a4238..993e25f 100644 --- a/src/core/lvmdevice.h +++ b/src/core/lvmdevice.h @@ -44,7 +44,7 @@ class LIBKPMCORE_EXPORT LvmDevice : public VolumeManagerDevice Q_DISABLE_COPY(LvmDevice) public: - LvmDevice(const QString& name, const QString& iconname = QString()); + LvmDevice(const QString& name, const QString& iconName = QString()); ~LvmDevice(); public: @@ -62,33 +62,33 @@ public: static QList scanSystemLVM(); static const QStringList getVGs(); - static const QStringList getPVs(const QString& vgname); - static const QStringList getLVs(const QString& vgname); + 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); - static qint64 getFreePE(const QString& vgname); - static QString getUUID(const QString& vgname); - static QString getField(const QString& fieldName, const QString& vgname = QString()); + static qint64 getPeSize(const QString& vgName); + static qint64 getTotalPE(const QString& vgName); + static qint64 getAllocatedPE(const QString& vgName); + static qint64 getFreePE(const QString& vgName); + static QString getUUID(const QString& vgName); + 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 createLV(Report& report, LvmDevice& dev, Partition& part, const QString& lvname); - static bool createLVSnapshot(Report& report, Partition& lvpart, const QString& name, const qint64 extents = 0); - static bool resizeLV(Report& report, Partition& part); - static bool deactivateLV(Report& report, const Partition& part); - static bool activateLV(Report& report, Partition& part); + static bool removeLV(Report& report, LvmDevice& d, Partition& p); + static bool createLV(Report& report, LvmDevice& d, Partition& p, const QString& lvName); + static bool createLVSnapshot(Report& report, Partition& p, const QString& name, const qint64 extents = 0); + static bool resizeLV(Report& report, Partition& p); + static bool deactivateLV(Report& report, const Partition& p); + static bool activateLV(Report& report, Partition& p); - static bool removePV(Report& report, LvmDevice& dev, const QString& pvPath); - static bool insertPV(Report& report, LvmDevice& dev, const QString& pvPath); + static bool removePV(Report& report, LvmDevice& d, 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 removeVG(Report& report, LvmDevice& dev); - 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 activateVG(Report& report, const 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 deactivateVG(Report& report, const LvmDevice& d); + static bool activateVG(Report& report, const LvmDevice& d); protected: @@ -103,7 +103,7 @@ protected: * */ 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: qint64 peSize() const { diff --git a/src/core/partitiontable.cpp b/src/core/partitiontable.cpp index 32c787c..680f5bb 100644 --- a/src/core/partitiontable.cpp +++ b/src/core/partitiontable.cpp @@ -39,13 +39,13 @@ /** Creates a new PartitionTable object with type MSDOS @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(), m_Children(), m_MaxPrimaries(maxPrimariesForTableType(type)), m_Type(type), - m_FirstUsable(first_usable), - m_LastUsable(last_usable) + m_FirstUsable(firstUsable), + m_LastUsable(lastUsable) { } diff --git a/src/core/partitiontable.h b/src/core/partitiontable.h index e38189d..d76cbdc 100644 --- a/src/core/partitiontable.h +++ b/src/core/partitiontable.h @@ -95,7 +95,7 @@ public: Q_FLAG(Flag) public: - PartitionTable(TableType type, qint64 first_usable, qint64 last_usable); + PartitionTable(TableType type, qint64 firstUsable, qint64 lastUsable); ~PartitionTable(); public: diff --git a/src/core/volumemanagerdevice.cpp b/src/core/volumemanagerdevice.cpp index 66172bc..94fbe6f 100644 --- a/src/core/volumemanagerdevice.cpp +++ b/src/core/volumemanagerdevice.cpp @@ -20,12 +20,12 @@ /** Constructs a Volume Manager Device with an empty PartitionTable. */ VolumeManagerDevice::VolumeManagerDevice(const QString& name, - const QString& devicenode, + const QString& deviceNode, const qint32 logicalSize, const qint64 totalLogical, - const QString& iconname, + const QString& iconName, Device::Type type) - : Device(name, devicenode, logicalSize, totalLogical, iconname, type) + : Device(name, deviceNode, logicalSize, totalLogical, iconName, type) { } diff --git a/src/core/volumemanagerdevice.h b/src/core/volumemanagerdevice.h index 62ad04e..550b49a 100644 --- a/src/core/volumemanagerdevice.h +++ b/src/core/volumemanagerdevice.h @@ -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. diff --git a/src/jobs/createvolumegroupjob.cpp b/src/jobs/createvolumegroupjob.cpp index 6bca909..4ba68da 100644 --- a/src/jobs/createvolumegroupjob.cpp +++ b/src/jobs/createvolumegroupjob.cpp @@ -24,14 +24,15 @@ #include /** Creates a new CreateVolumeGroupJob - @param vgname LVM Volume Group name - @param pvlist List of LVM Physical Volumes + * @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 */ -CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize) : +CreateVolumeGroupJob::CreateVolumeGroupJob(const QString& vgName, const QStringList& pvList, const qint32 peSize) : Job(), - m_vgName(vgname), - m_pvList(pvlist), - m_PESize(pesize) + m_vgName(vgName), + m_pvList(pvList), + m_PESize(peSize) { } diff --git a/src/jobs/createvolumegroupjob.h b/src/jobs/createvolumegroupjob.h index 76a2f2c..02b13cb 100644 --- a/src/jobs/createvolumegroupjob.h +++ b/src/jobs/createvolumegroupjob.h @@ -30,7 +30,7 @@ class QString; class CreateVolumeGroupJob : public Job { public: - CreateVolumeGroupJob(const QString& vgname, const QStringList& pvlist, const qint32 pesize); + CreateVolumeGroupJob(const QString& vgName, const QStringList& pvList, const qint32 peSize); public: bool run(Report& parent) override; diff --git a/src/jobs/deactivatelogicalvolumejob.cpp b/src/jobs/deactivatelogicalvolumejob.cpp index e53d412..7591701 100644 --- a/src/jobs/deactivatelogicalvolumejob.cpp +++ b/src/jobs/deactivatelogicalvolumejob.cpp @@ -27,9 +27,9 @@ /** Creates a new DeactivateLogicalVolumeJob */ -DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& dev, const QStringList lvPaths) : +DeactivateLogicalVolumeJob::DeactivateLogicalVolumeJob(const VolumeManagerDevice& d, const QStringList lvPaths) : Job(), - m_Device(dev), + m_Device(d), m_LVList(lvPaths) { } diff --git a/src/jobs/deactivatevolumegroupjob.cpp b/src/jobs/deactivatevolumegroupjob.cpp index 1f8694b..56f7c09 100644 --- a/src/jobs/deactivatevolumegroupjob.cpp +++ b/src/jobs/deactivatevolumegroupjob.cpp @@ -25,9 +25,9 @@ /** Deactivate LVM Volume Group */ -DeactivateVolumeGroupJob::DeactivateVolumeGroupJob(VolumeManagerDevice& dev) : +DeactivateVolumeGroupJob::DeactivateVolumeGroupJob(VolumeManagerDevice& d) : Job(), - m_Device(dev) + m_Device(d) { } diff --git a/src/jobs/movephysicalvolumejob.cpp b/src/jobs/movephysicalvolumejob.cpp index 6d71247..8f13985 100644 --- a/src/jobs/movephysicalvolumejob.cpp +++ b/src/jobs/movephysicalvolumejob.cpp @@ -24,11 +24,12 @@ #include /** 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(), - m_Device(dev), - m_PartList(partlist) + m_Device(d), + m_PartList(partList) { } diff --git a/src/jobs/removevolumegroupjob.cpp b/src/jobs/removevolumegroupjob.cpp index 9c29614..d5026ae 100644 --- a/src/jobs/removevolumegroupjob.cpp +++ b/src/jobs/removevolumegroupjob.cpp @@ -25,9 +25,9 @@ /** Creates a new RemoveVolumeGroupJob */ -RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& dev) : +RemoveVolumeGroupJob::RemoveVolumeGroupJob(VolumeManagerDevice& d) : Job(), - m_Device(dev) + m_Device(d) { } diff --git a/src/ops/createvolumegroupoperation.cpp b/src/ops/createvolumegroupoperation.cpp index 2651bbe..063e909 100644 --- a/src/ops/createvolumegroupoperation.cpp +++ b/src/ops/createvolumegroupoperation.cpp @@ -27,11 +27,14 @@ #include /** 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(), - m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgname, pvlist, pesize)), - m_PVList(pvlist) + m_CreateVolumeGroupJob(new CreateVolumeGroupJob(vgName, pvList, peSize)), + m_PVList(pvList) { addJob(createVolumeGroupJob()); } @@ -41,9 +44,8 @@ QString CreateVolumeGroupOperation::description() const 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; } @@ -54,9 +56,9 @@ void CreateVolumeGroupOperation::preview() void CreateVolumeGroupOperation::undo() { - for (const auto &pvpath : PVList()) { - if (LvmDevice::s_DirtyPVs.contains(pvpath)) { - LvmDevice::s_DirtyPVs.removeAll(pvpath); + for (const auto &pvPath : PVList()) { + if (LvmDevice::s_DirtyPVs.contains(pvPath)) { + LvmDevice::s_DirtyPVs.removeAll(pvPath); } } } diff --git a/src/ops/createvolumegroupoperation.h b/src/ops/createvolumegroupoperation.h index 8f49fc5..2919e36 100644 --- a/src/ops/createvolumegroupoperation.h +++ b/src/ops/createvolumegroupoperation.h @@ -37,7 +37,7 @@ class LIBKPMCORE_EXPORT CreateVolumeGroupOperation : public Operation friend class OperationStack; public: - CreateVolumeGroupOperation(const QString& vgname, const QStringList& pvlist, const qint32 pesize = 4); + CreateVolumeGroupOperation(const QString& vgName, const QStringList& pvList, const qint32 peSize = 4); public: QString iconName() const override { diff --git a/src/ops/deactivatevolumegroupoperation.cpp b/src/ops/deactivatevolumegroupoperation.cpp index a72dc04..c9a5fe9 100644 --- a/src/ops/deactivatevolumegroupoperation.cpp +++ b/src/ops/deactivatevolumegroupoperation.cpp @@ -28,11 +28,11 @@ /** Creates a new RemoveVolumeGroupOperation. */ -DeactivateVolumeGroupOperation::DeactivateVolumeGroupOperation(VolumeManagerDevice& dev) : +DeactivateVolumeGroupOperation::DeactivateVolumeGroupOperation(VolumeManagerDevice& d) : Operation(), - m_DeactivateVolumeGroupJob(new DeactivateVolumeGroupJob(dev)), - m_DeactivateLogicalVolumeJob(new DeactivateLogicalVolumeJob(dev)), - m_Device(dev) + m_DeactivateVolumeGroupJob(new DeactivateVolumeGroupJob(d)), + m_DeactivateLogicalVolumeJob(new DeactivateLogicalVolumeJob(d)), + m_Device(d) { addJob(deactivateLogicalVolumeJob()); addJob(deactivateVolumeGroupJob()); diff --git a/src/ops/deactivatevolumegroupoperation.h b/src/ops/deactivatevolumegroupoperation.h index d6675d2..bdd94b6 100644 --- a/src/ops/deactivatevolumegroupoperation.h +++ b/src/ops/deactivatevolumegroupoperation.h @@ -38,7 +38,7 @@ class LIBKPMCORE_EXPORT DeactivateVolumeGroupOperation : public Operation friend class OperationStack; public: - DeactivateVolumeGroupOperation(VolumeManagerDevice& dev); + DeactivateVolumeGroupOperation(VolumeManagerDevice& d); public: QString iconName() const override { diff --git a/src/ops/removevolumegroupoperation.cpp b/src/ops/removevolumegroupoperation.cpp index 73d13d2..f4cc861 100644 --- a/src/ops/removevolumegroupoperation.cpp +++ b/src/ops/removevolumegroupoperation.cpp @@ -26,10 +26,10 @@ /** Creates a new RemoveVolumeGroupOperation. */ -RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& dev) : +RemoveVolumeGroupOperation::RemoveVolumeGroupOperation(VolumeManagerDevice& d) : Operation(), - m_RemoveVolumeGroupJob(new RemoveVolumeGroupJob(dev)), - m_Device(dev) + m_RemoveVolumeGroupJob(new RemoveVolumeGroupJob(d)), + m_Device(d) { addJob(removeVolumeGroupJob()); } diff --git a/src/ops/removevolumegroupoperation.h b/src/ops/removevolumegroupoperation.h index 0d8130a..998c947 100644 --- a/src/ops/removevolumegroupoperation.h +++ b/src/ops/removevolumegroupoperation.h @@ -36,7 +36,7 @@ class LIBKPMCORE_EXPORT RemoveVolumeGroupOperation : public Operation friend class OperationStack; public: - RemoveVolumeGroupOperation(VolumeManagerDevice& dev); + RemoveVolumeGroupOperation(VolumeManagerDevice& d); public: QString iconName() const override { diff --git a/src/ops/resizevolumegroupoperation.cpp b/src/ops/resizevolumegroupoperation.cpp index 6100915..b209e32 100644 --- a/src/ops/resizevolumegroupoperation.cpp +++ b/src/ops/resizevolumegroupoperation.cpp @@ -30,22 +30,22 @@ /** Creates a new ResizeVolumeGroupOperation. @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(), - m_Device(dev), + m_Device(d), m_TargetList(partlist), - m_CurrentList(LvmDevice::getPVs(dev.name())), + m_CurrentList(LvmDevice::getPVs(d.name())), m_GrowVolumeGroupJob(nullptr), m_ShrinkVolumeGroupJob(nullptr), m_MovePhysicalVolumeJob(nullptr) { - const QStringList clist = currentList(); + const QStringList curList = currentList(); m_TargetSize = FS::lvm2_pv::getPVSize(targetList()); m_CurrentSize = FS::lvm2_pv::getPVSize(currentList()); - QStringList toRemoveList = clist; + QStringList toRemoveList = curList; for (QString path : partlist) { if (toRemoveList.contains(path)) { toRemoveList.removeAll(path); @@ -53,28 +53,28 @@ ResizeVolumeGroupOperation::ResizeVolumeGroupOperation(LvmDevice& dev, const QSt } QStringList toInsertList = partlist; - for (QString path : clist) { + for (QString path : curList) { if (toInsertList.contains(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 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)) { // *ABORT* can't move - } else if (partlist == clist) { + } else if (partlist == curList) { // *DO NOTHING* } else { if (!toInsertList.isEmpty()) { - m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(dev, toInsertList, ResizeVolumeGroupJob::Grow); + m_GrowVolumeGroupJob = new ResizeVolumeGroupJob(d, toInsertList, ResizeVolumeGroupJob::Grow); addJob(growVolumeGroupJob()); } if (!toRemoveList.isEmpty()) { - m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(dev, toRemoveList); - m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(dev, toRemoveList, ResizeVolumeGroupJob::Shrink); + m_MovePhysicalVolumeJob = new MovePhysicalVolumeJob(d, toRemoveList); + m_ShrinkVolumeGroupJob = new ResizeVolumeGroupJob(d, toRemoveList, ResizeVolumeGroupJob::Shrink); addJob(movePhysicalVolumeJob()); addJob(shrinkvolumegroupjob()); } @@ -94,10 +94,10 @@ bool ResizeVolumeGroupOperation::targets(const Device& d) const return d == device(); } -bool ResizeVolumeGroupOperation::targets(const Partition& part) const +bool ResizeVolumeGroupOperation::targets(const Partition& p) const { for (QString partPath : targetList()) { - if (partPath == part.partitionPath()) { + if (partPath == p.partitionPath()) { return true; } }