[PATCH 3/3] Enforce maximum partition sizes. (#528276)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 storage/partitioning.py |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/storage/partitioning.py b/storage/partitioning.py
index b9a5592..bad28f1 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
-- 
1.6.2.5

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux