Partially revert 252b108660.

That commit broke LVM support.
This commit is contained in:
Andrius Štikonas 2018-07-15 00:28:38 +01:00
parent 51780a6297
commit f572681684
1 changed files with 5 additions and 16 deletions

View File

@ -90,18 +90,18 @@ LvmDevice::~LvmDevice()
void LvmDevice::initPartitions() void LvmDevice::initPartitions()
{ {
qint64 firstUsable = 0; qint64 firstUsable = 0;
qint64 lastusable = totalPE() - 1; qint64 lastUsable = totalPE() - 1;
PartitionTable* pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastusable); PartitionTable* pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastUsable);
for (const auto &p : scanPartitions(pTable)) { for (const auto &p : scanPartitions(pTable)) {
LVSizeMap()->insert(p->partitionPath(), p->length()); LVSizeMap()->insert(p->partitionPath(), p->length());
pTable->append(p); pTable->append(p);
} }
if (!pTable) if (pTable)
pTable->updateUnallocated(*this); pTable->updateUnallocated(*this);
else else
pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastusable); pTable = new PartitionTable(PartitionTable::vmd, firstUsable, lastUsable);
setPartitionTable(pTable); setPartitionTable(pTable);
} }
@ -109,8 +109,6 @@ void LvmDevice::initPartitions()
/** /**
* Scan LVM LV Partitions * Scan LVM LV Partitions
* *
* This deletes pTable when LVM scanning error is encountered
*
* @param pTable Virtual PartitionTable of LVM device * @param pTable Virtual PartitionTable of LVM device
* @return an initialized Partition(LV) list * @return an initialized Partition(LV) list
*/ */
@ -119,13 +117,7 @@ const QList<Partition*> LvmDevice::scanPartitions(PartitionTable* pTable) const
QList<Partition*> pList; QList<Partition*> pList;
for (const auto &lvPath : partitionNodes()) { for (const auto &lvPath : partitionNodes()) {
Partition *p = scanPartition(lvPath, pTable); Partition *p = scanPartition(lvPath, pTable);
if (p) pList.append(p);
pList.append(p);
else {
pList.clear();
delete pTable;
break;
}
} }
return pList; return pList;
} }
@ -149,9 +141,6 @@ Partition* LvmDevice::scanPartition(const QString& lvPath, PartitionTable* pTabl
activateLV(lvPath); activateLV(lvPath);
qint64 lvSize = getTotalLE(lvPath); qint64 lvSize = getTotalLE(lvPath);
if (lvSize == -1)
return nullptr;
qint64 startSector = mappedSector(lvPath, 0); qint64 startSector = mappedSector(lvPath, 0);
qint64 endSector = startSector + lvSize - 1; qint64 endSector = startSector + lvSize - 1;