Various small cleanups.

This commit is contained in:
Andrius Štikonas 2016-07-31 23:59:18 +01:00
parent 8a3ba0a4a6
commit 510feefc55
2 changed files with 17 additions and 20 deletions

View File

@ -59,7 +59,7 @@ void LvmDevice::initPartitions()
qint64 lastusable = totalPE() - 1; qint64 lastusable = totalPE() - 1;
PartitionTable* pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastusable); PartitionTable* pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastusable);
foreach (Partition* p, scanPartitions(*this, pTable)) { foreach (Partition* p, scanPartitions(pTable)) {
pTable->append(p); pTable->append(p);
} }
@ -69,25 +69,25 @@ void LvmDevice::initPartitions()
} }
/** /**
* @returns sorted Partition(LV) Array * @return sorted Partition(LV) Array
*/ */
QList<Partition*> LvmDevice::scanPartitions(const LvmDevice& dev, PartitionTable* pTable) const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
{ {
QList<Partition*> pList; QList<Partition*> pList;
foreach (QString lvPath, lvPathList()) { foreach (QString lvPath, lvPathList()) {
pList.append(scanPartition(lvPath, dev, pTable)); pList.append(scanPartition(lvPath, pTable));
} }
return pList; return pList;
} }
/** /**
* @returns sorted Partition(LV) Array * @return sorted Partition (LV) Array
*/ */
Partition* LvmDevice::scanPartition(const QString& lvpath, const LvmDevice& dev, PartitionTable* pTable) const Partition* LvmDevice::scanPartition(const QString& lvpath, PartitionTable* pTable) const
{ {
/* /*
* NOTE: * NOTE:
* LVM partition have 2 different start and end sector value * LVM partition has 2 different start and end sector values
* 1. representing the actual LV start from 0 -> size of LV - 1 * 1. representing the actual LV start from 0 -> size of LV - 1
* 2. representing abstract LV's sector inside a VG partitionTable * 2. representing abstract LV's sector inside a VG partitionTable
* start from last sector + 1 of last Partitions -> size of LV - 1 * start from last sector + 1 of last Partitions -> size of LV - 1
@ -116,7 +116,7 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, const LvmDevice& dev,
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(dev.logicalSize()); luksFs->setLogicalSectorSize(logicalSize());
if (isCryptOpen) { if (isCryptOpen) {
luksFs->loadInnerFileSystem(lvpath, mapperNode); luksFs->loadInnerFileSystem(lvpath, mapperNode);
@ -127,7 +127,7 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, const LvmDevice& dev,
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)) / dev.logicalSize()); luksFs->setSectorsUsed((freeSpaceInfo.used() + luksFs->getPayloadOffset(lvpath)) / logicalSize());
} }
} else { } else {
mounted = false; mounted = false;
@ -154,7 +154,7 @@ Partition* LvmDevice::scanPartition(const QString& lvpath, const LvmDevice& dev,
} }
Partition* part = new Partition(pTable, Partition* part = new Partition(pTable,
dev, *this,
PartitionRole(r), PartitionRole(r),
fs, fs,
startSector, startSector,
@ -267,9 +267,9 @@ 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 * @param vgname the name of LVM Volume Group
* @returns raw output of command output, usully with manay 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)
@ -399,7 +399,7 @@ bool LvmDevice::movePV(Report& report, LvmDevice& dev, const QString& pvPath, co
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)
{ {
//TODO: check that all the pv in pvlist is lvm2_pv //TODO: check that all the pv in pvlist are lvm2_pv
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;

View File

@ -32,9 +32,7 @@ class PartitionTable;
class CreatePartitionTableOperation; class CreatePartitionTableOperation;
class SmartStatus; class SmartStatus;
/** A device. /** Represents LVM Volume Group.
Represents a device like /dev/sda.
Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions. Devices are the outermost entity; they contain a PartitionTable that itself contains Partitions.
@ -49,8 +47,8 @@ public:
LvmDevice(const QString& name, const QString& iconname = QString()); LvmDevice(const QString& name, const QString& iconname = QString());
public: public:
QList<Partition*> scanPartitions(const LvmDevice& dev, PartitionTable* pTable) const; QList<Partition*> scanPartitions(PartitionTable* pTable) const;
Partition* scanPartition(const QString& lvPath, const LvmDevice& dev, PartitionTable* pTable) const; Partition* scanPartition(const QString& lvPath, PartitionTable* pTable) const;
static QList<LvmDevice*> scanSystemLVM(); static QList<LvmDevice*> scanSystemLVM();
@ -111,4 +109,3 @@ private:
}; };
#endif #endif