[PATCH master] Check size limits on pre-existing partitions

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

 



When editing a pre-existing partition and changing its format type we
need to re-check the size limits. eg. mounting a partition on /boot/efi
needs to make sure it is <= 256M

Resolves: rhbz#684860
---
 pyanaconda/storage/__init__.py     |    8 ++++++
 pyanaconda/storage/devices.py      |   48 ++++++++++++++++++++++++++++++++++++
 pyanaconda/storage/partitioning.py |   12 +--------
 3 files changed, 57 insertions(+), 11 deletions(-)

diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index a0cbdfa..b000573 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -1102,6 +1102,14 @@ class Storage(object):
                                 % {'mount': mount, 'size': size,
                                    'productName': productName})
 
+        for (mount, device) in filesystems.items():
+            problem = filesystems[mount].checkSize()
+            if problem:
+                errors.append(_("Your %s partition is too %s for %s formatting "
+                                "(allowable size is %d MB to %d MB)")
+                              % (mount, problem, device.format.name,
+                                 device.minSize, device.maxSize))
+
         usb_disks = []
         firewire_disks = []
         for disk in self.disks:
diff --git a/pyanaconda/storage/devices.py b/pyanaconda/storage/devices.py
index 80bb7be..303856b 100644
--- a/pyanaconda/storage/devices.py
+++ b/pyanaconda/storage/devices.py
@@ -932,6 +932,19 @@ class StorageDevice(Device):
                     break
         return grow
 
+    def checkSize(self):
+        """ Check to make sure the size of the device is allowed by the
+            format used.
+
+            return None is all is ok
+            return large or small depending on the problem
+        """
+        problem = None
+        if self.format.maxSize and self.size > self.format.maxSize:
+            problem = _("large")
+        elif self.format.minSize and self.size < self.format.minSize:
+            problem = _("small")
+        return problem
 
 class DiskDevice(StorageDevice):
     """ A disk """
@@ -1595,6 +1608,24 @@ class PartitionDevice(StorageDevice):
         return super(PartitionDevice, self).resizable and \
                self.disk.type != 'dasd'
 
+    def checkSize(self):
+        """ Check to make sure the size of the device is allowed by the
+            format used.
+
+            return None is all is ok
+            return large or small depending on the problem
+        """
+        problem = None
+        if self.format.maxSize and self.size > self.format.maxSize:
+            problem = _("large")
+        elif (self.format.minSize and
+              (not self.req_grow and
+               self.size < self.format.minSize) or
+              (self.req_grow and self.req_max_size and
+               self.req_max_size < self.format.minSize)):
+            problem = _("small")
+        return problem
+
 class DMDevice(StorageDevice):
     """ A device-mapper device """
     _type = "dm"
@@ -2553,6 +2584,23 @@ class LVMLogicalVolumeDevice(DMDevice):
         # is different (ofcourse)
         return "rd_LVM_LV=%s/%s" % (self.vg.name, self._name)
 
+    def checkSize(self):
+        """ Check to make sure the size of the device is allowed by the
+            format used.
+
+            return None is all is ok
+            return large or small depending on the problem
+        """
+        problem = None
+        if self.format.maxSize and self.size > self.format.maxSize:
+            problem = _("large")
+        elif (self.format.minSize and
+              (not self.req_grow and
+               self.size < self.format.minSize) or
+              (self.req_grow and self.req_max_size and
+               self.req_max_size < self.format.minSize)):
+            problem = _("small")
+        return problem
 
 class MDRaidArrayDevice(StorageDevice):
     """ An mdraid (Linux RAID) device. """
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index e8f3921..aebd7b8 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -1000,17 +1000,7 @@ def allocatePartitions(storage, disks, partitions, freespace, bootloader=None):
             if _part.req_grow:
                 current_free = None
 
-            problem = None
-            if _part.format.maxSize and _part.req_size > _part.format.maxSize:
-                problem = "large"
-            elif (_part.format.minSize and
-                  (not _part.req_grow and
-                   _part.req_size < _part.format.minSize) or
-                  (_part.req_grow and _part.req_max_size and
-                   _part.req_max_size < _part.format.minSize)):
-                # format max/min size also enforced in growPartitions
-                problem = "small"
-
+            problem = _part.checkSize()
             if problem:
                 raise PartitioningError("partition is too %s for %s formatting "
                                         "(allowable size is %d MB to %d MB)"
-- 
1.7.4

_______________________________________________
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