Add currentSize method to the PartitionDevice class (#565822)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ack.
On Tue, 16 Feb 2010, Hans de Goede wrote:
PartitionDevice was inheriting the currentSize property from StorageDevice,
but that uses partedDevice.getSize() which returns 1024 when called on
extended partitions (as that is what the kernel reports).
This causes _setTargetSize() to try and change the extended partition geometry
even when called with the current extended partition geometry size, as
currentSize was mis-reporting the extended partition size. Since
we do end sector alignment now a days when changing the partition geometry,
we could end up making the extended partition to small to hold the
last logical partition resulting in a:
PartitionException: Unable to satisfy all constraints on the partition.
Error. This patch fixes this by adding a currentSize method to the
PartitionDevice class, which properly reports the currentSize for extended
partitions.
---
storage/devices.py | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
# FIXME: Validate size, but only if this is a new partition.
# For existing partitions we will get the size from
@@ -1231,6 +1232,7 @@ class PartitionDevice(StorageDevice):
# this is in MB
self._size = self.partedPartition.getSize()
+ self._currentSize = self._size
self.targetSize = self._size