[RHEL 7.2 - PATCH 4/5] Validate format size versus device size (#1178884)

Robert Marshall rmarshall at redhat.com
Mon Jul 27 18:40:11 UTC 2015


From: David Lehman <dlehman at redhat.com>

Prevents assignment of formats to a device that are much larger than the
maximum allowable size.  EG: Assigning PPC PReP Boot an excessively
large amount of space.

Cherry pick taken from commmit 26b23b1.

Resolves: rhbz#1178884
---
 blivet/devices/storage.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index a26b561..740be2e 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -610,6 +610,13 @@ class StorageDevice(Device):
             # FIXME: self.format.status doesn't mean much
             raise errors.DeviceError("cannot replace active format", self.name)
 
+        # check device size against format limits
+        if not fmt.exists:
+            if fmt.maxSize and fmt.maxSize < self.size:
+                raise errors.DeviceError("device is too large for new format")
+            elif fmt.minSize and fmt.minSize > self.size:
+                raise errors.DeviceError("device is too small for new format")
+
         self._format = fmt
         self._format.device = self.path
 
-- 
1.8.3.1



More information about the anaconda-patches mailing list