Fix unallocated space calculation in the presence of LVM RAID partitions.

BUG: 396776
This commit is contained in:
Andrius Štikonas 2018-07-24 21:39:55 +01:00
parent 8b28001ae2
commit 4fcbb540e0
1 changed files with 18 additions and 10 deletions

View File

@ -402,18 +402,26 @@ void PartitionTable::insertUnallocated(const Device& d, PartitionNode* p, qint64
}
}
// Take care of the free space between the end of the last child and the end
// of the device or the extended partition.
qint64 parentEnd = lastUsable();
if (!p->isRoot()) {
Partition* extended = dynamic_cast<Partition*>(p);
parentEnd = extended ? extended->lastSector() : -1;
Q_ASSERT(extended);
if (d.type() == Device::Type::LVM_Device)
{
const LvmDevice& lvm = static_cast<const LvmDevice&>(d);
p->insert(createUnallocated(d, *p, lastEnd, lastEnd + lvm.freePE() - 1));
}
else
{
// Take care of the free space between the end of the last child and the end
// of the device or the extended partition.
qint64 parentEnd = lastUsable();
if (parentEnd >= firstUsable() && parentEnd >= lastEnd)
p->insert(createUnallocated(d, *p, lastEnd, parentEnd));
if (!p->isRoot()) {
Partition* extended = dynamic_cast<Partition*>(p);
parentEnd = extended ? extended->lastSector() : -1;
Q_ASSERT(extended);
}
if (parentEnd >= firstUsable() && parentEnd >= lastEnd)
p->insert(createUnallocated(d, *p, lastEnd, parentEnd));
}
}
/** Updates the unallocated Partitions for this PartitionTable.