[master 1/1] Fix currentSize for extended partitions (#1254899)
vojtechtrefny
installerbot-noreply at redhat.com
Thu Aug 20 11:39:06 UTC 2015
From: Vojtech Trefny <vtrefny at redhat.com>
It isn't possible to use size from /sys for extended partitions
because it always reports it to be 2 sectors.
Signed-off-by: Vojtech Trefny <vtrefny at redhat.com>
---
blivet/devices/partition.py | 23 ++++++++++++++++++++++-
blivet/udev.py | 4 ++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/blivet/devices/partition.py b/blivet/devices/partition.py
index 13273ed..34b4d79 100644
--- a/blivet/devices/partition.py
+++ b/blivet/devices/partition.py
@@ -43,7 +43,7 @@
from .device import Device
from .storage import StorageDevice
from .dm import DMDevice
-from .lib import devicePathToName, deviceNameToDiskByPath
+from .lib import devicePathToName, deviceNameToDiskByPath, LINUX_SECTOR_SIZE
DEFAULT_PART_SIZE = Size("500MiB")
@@ -192,6 +192,10 @@ def __init__(self, name, fmt=None,
self.req_start_sector = start
self.req_end_sector = end
+ # update currentSize again now when we have partedPartition and
+ # information about partType
+ self.updateSize()
+
def __repr__(self):
s = StorageDevice.__repr__(self)
s += (" grow = %(grow)s max size = %(maxsize)s bootable = %(bootable)s\n"
@@ -775,6 +779,23 @@ def _unalignedMaxPartSize(self):
return maxPartSize
+ def readCurrentSize(self):
+ # sys reports wrong size for extended partitions (1 KiB)
+ if self.isExtended:
+ log_method_call(self, exists=self.exists, path=self.path,
+ sysfsPath=self.sysfsPath)
+ size = Size(0)
+ if self.exists and os.path.exists(self.path) and \
+ os.path.isdir(self.sysfsPath):
+ blocks = udev.device_get_part_size(udev.get_device(self.sysfsPath))
+ if blocks:
+ size = Size(int(blocks) * LINUX_SECTOR_SIZE)
+
+ else:
+ size = super(PartitionDevice, self).readCurrentSize()
+
+ return size
+
@property
def minSize(self):
min_size = super(PartitionDevice, self).minSize
diff --git a/blivet/udev.py b/blivet/udev.py
index ed1af67..94ad86e 100644
--- a/blivet/udev.py
+++ b/blivet/udev.py
@@ -171,6 +171,10 @@ def device_get_label(udev_info):
""" Get the label from the device's format as reported by udev. """
return udev_info.get("ID_FS_LABEL")
+def device_get_part_size(udev_info):
+ """ Get size for specified partition as reported by udev. """
+ return udev_info.get("ID_PART_ENTRY_SIZE")
+
def device_is_dm(info):
""" Return True if the device is a device-mapper device. """
dm_dir = os.path.join(device_get_sysfs_path(info), "dm")
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/b924f0691a3e3a1d8fb4e2ec4a58c907218fb67b
More information about the anaconda-patches
mailing list