diff options
author | David Lehman <dlehman@redhat.com> | 2010-02-03 13:11:53 -0600 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2010-02-03 13:11:53 -0600 |
commit | 11a9b647287467c81456525dbef5f5b54ec72d85 (patch) | |
tree | 216cdb8e7d6ee8c9a5ba882d45bc1ce733797c56 /storage | |
parent | e3567a995190a89f66a4925523f19d14d2e051f7 (diff) | |
download | anaconda-11a9b647287467c81456525dbef5f5b54ec72d85.tar.gz anaconda-11a9b647287467c81456525dbef5f5b54ec72d85.tar.xz anaconda-11a9b647287467c81456525dbef5f5b54ec72d85.zip |
Enforce maximum partition sizes. (#528276)
Diffstat (limited to 'storage')
-rw-r--r-- | storage/partitioning.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py index b9a55929f..bad28f108 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -701,6 +701,10 @@ def addPartition(disklabel, free, part_type, size): start=start, end=end) + max_length = disklabel.partedDisk.maxPartitionLength + if max_length and new_geom.length > max_length: + raise PartitioningError("requested size exceeds maximum allowed") + # create the partition and add it to the disk partition = parted.Partition(disk=disklabel.partedDisk, type=part_type, @@ -1124,14 +1128,13 @@ class Request(object): sector_size = partition.partedPartition.disk.device.sectorSize if partition.req_grow: - max_size = partition.req_max_size - format_max_size = partition.format.maxSize - if not max_size or \ - (format_max_size and format_max_size < max_size): - max_size = format_max_size - - if max_size: - max_sectors = sizeToSectors(max_size, sector_size) + limits = filter(lambda l: l > 0, + [sizeToSectors(partition.req_max_size, sector_size), + sizeToSectors(partition.format.maxSize, sector_size), + partition.partedPartition.disk.maxPartitionLength]) + + if limits: + max_sectors = min(limits) self.max_growth = max_sectors - self.base @property |