[master 3/5] Validate new formats against current device size.
dwlehman
installerbot-noreply at redhat.com
Wed Jul 1 17:30:19 UTC 2015
From: David Lehman <dlehman at redhat.com>
This prevents, eg: assigning PReP boot format to a device much larger
than the maximum size allowed for that format.
---
blivet/devices/storage.py | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 98b0f1e..d90b3f5 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -686,6 +686,12 @@ def _setFormat(self, fmt):
# FIXME: self.format.status doesn't mean much
raise errors.DeviceError("cannot replace active format", self.name)
+ # check device size against format limits
+ 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
self._updateNetDevMountOption()
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/d0b91ef37616dccf7af3ad92cdd44f4d90f47f87
More information about the anaconda-patches
mailing list