diff options
author | David Lehman <dlehman@redhat.com> | 2009-03-19 22:17:16 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2009-03-19 23:17:35 -0500 |
commit | 91347c23b46687114b1d7a4f02867129170bba84 (patch) | |
tree | 29b6014c2a5436a093056648989112a083f2c24f | |
parent | 08924fe8952b93962eeb7b4f2ee2d999b24da71a (diff) | |
download | anaconda-91347c23b46687114b1d7a4f02867129170bba84.tar.gz anaconda-91347c23b46687114b1d7a4f02867129170bba84.tar.xz anaconda-91347c23b46687114b1d7a4f02867129170bba84.zip |
Add boot partition size limit properties and size validation method.
Also, don't require that partitions be bootable in advance of being
identified as the boot device. We will set the boot device's boot
flag explicity elsewhere.
-rw-r--r-- | platform.py | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/platform.py b/platform.py index 71db883a8..330601adb 100644 --- a/platform.py +++ b/platform.py @@ -41,6 +41,8 @@ class Platform(object): _diskType = parted.diskType["msdos"] _minimumSector = 0 _supportsMdRaidBoot = False + _minBootPartSize = 50 + _maxBootPartSize = 0 def __init__(self, anaconda): """Creates a new Platform object. This is basically an abstract class. @@ -127,8 +129,27 @@ class Platform(object): """Does the platform support /boot on MD RAID?""" return self._supportsMdRaidBoot + @property + def minBootPartSize(self): + return self._minBootPartSize + + @property + def maxBootPartSize(self): + return self._maxBootPartSize + + def validBootPartSize(self, size): + """ Is the given size (in MB) acceptable for a boot device? """ + if not isinstance(size, int) and not isinstance(size, float): + return False + + return ((not self.minBootPartSize or size >= self.minBootPartSize) + and + (not self.maxBootPartSize or size <= self.maxBootPartSize)) + class EFI(Platform): _diskType = parted.diskType["gpt"] + _minBootPartSize = 50 + _maxBootPartSize = 256 def bootDevice(self): mntDict = self._mntDict() @@ -157,7 +178,7 @@ class EFI(Platform): # Only add the EFI partition to the default set if there's not already # one on the system. - if len(filter(lambda dev: dev.format.type == "efi" and dev.size < 256 and dev.bootable, + if len(filter(lambda dev: dev.format.type == "efi" and self.validBootPartSize(dev.size), self.anaconda.id.storage.partitions)) == 0: ret.append(("/boot/efi", "efi", 50, 200, 1, 0)) @@ -207,6 +228,9 @@ class PPC(Platform): return self._ppcMachine class IPSeriesPPC(PPC): + _minBootPartSize = 4 + _maxBootPartSize = 10 + def bootDevice(self): bootDev = None @@ -248,13 +272,15 @@ class IPSeriesPPC(PPC): class NewWorldPPC(PPC): _diskType = parted.diskType["mac"] + _minBootPartSize = (800.00 / 1024.00) + _maxBootPartSize = 1 def bootDevice(self): bootDev = None for part in self.anaconda.id.storage.partitions: # XXX do we need to also check the size? - if part.format.type == "hfs" and part.bootable: + if part.format.type == "hfs" and self.validBootPartSize(part.size): bootDev = part return bootDev @@ -340,6 +366,20 @@ class X86(EFI): def isEfi(self): return self._isEfi + @property + def maxBootPartSize(self): + if self.isEfi: + return EFI._maxBootPartSize + else: + return Platform._maxBootPartSize + + @property + def minBootPartSize(self): + if self.isEFI: + return EFI._minBootPartSize + else: + return Platform._minBootPartSize + def setDefaultPartitioning(self): if self.isEfi: return EFI.setDefaultPartitioning(self) |