[master 1/5] Validate new formats against current device size.
dwlehman
installerbot-noreply at redhat.com
Wed Jul 8 21:13:15 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 | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/blivet/devices/storage.py b/blivet/devices/storage.py
index 98b0f1e..a095f6f 100644
--- a/blivet/devices/storage.py
+++ b/blivet/devices/storage.py
@@ -686,6 +686,13 @@ 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 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
self._updateNetDevMountOption()
--
To view this commit on github, visit https://github.com/rhinstaller/blivet/commit/26b23b13eba437ffbdbcd60013d3c202a7546cbb
More information about the anaconda-patches
mailing list