change the way the number of free sectors before and after a partition is

calculated: 

In case of the free sectors after a partition, we used to just add the length
of the following unallocated partition to the last sector. This does not work
for extended partitions where unallocated partitions have
number_of_sectors_per_track free space before AND after them.

This is because if a new partition is created in place of the unallocated space
and this partition is followed by another logical, we need two times
number_of_sectors_per_track for two extended boot records.

If, however, the partition in question is simply resized to fill up all space
following it (and is still followed by a logical), we only need ONE EBR.

To solve this, we now use the difference between the following partition's last
sector and the partition's last sector instead.

The same is true for free sectors preceding a partition, of course.

svn path=/trunk/extragear/sysadmin/partitionmanager/; revision=1115127
This commit is contained in:
Volker Lanz 2010-04-15 10:20:36 +00:00
parent c97d7cd15a
commit cc1542fa84
1 changed files with 6 additions and 2 deletions

View File

@ -67,8 +67,10 @@ qint64 PartitionTable::freeSectorsBefore(const Partition& p) const
{
const Partition* pred = predecessor(p);
// due to the space required for extended boot records the
// below is NOT the same as pred->length()
if (pred && pred->roles().has(PartitionRole::Unallocated))
return pred->length();
return p.firstSector() - pred->firstSector();
return 0;
}
@ -82,8 +84,10 @@ qint64 PartitionTable::freeSectorsAfter(const Partition& p) const
{
const Partition* succ = successor(p);
// due to the space required for extended boot records the
// below is NOT the same as succ->length()
if (succ && succ->roles().has(PartitionRole::Unallocated))
return succ->length();
return succ->lastSector() - p.lastSector();
return 0;
}