Looks ok, Regards, Hans On 05/29/2009 02:11 AM, David Lehman wrote:
Ignore preexisting disks with too many partitions. Also make sure we don't try to allocate more than the maximum allowed number of partitions from a disk during partitioning. --- storage/devicetree.py | 37 +++++++++++++++++++++++++++++++++++++ storage/partitioning.py | 9 +++++++++ 2 files changed, 46 insertions(+), 0 deletions(-) diff --git a/storage/devicetree.py b/storage/devicetree.py index f026348..c2241c5 100644 --- a/storage/devicetree.py +++ b/storage/devicetree.py @@ -21,6 +21,7 @@ # import os +import sys import block import re @@ -33,6 +34,7 @@ import formats import devicelibs.mdraid from udev import * from iutil import log_method_call +from constants import productName import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -120,6 +122,31 @@ def getLUKSPassphrase(intf, device, globalPassphrase): return (passphrase, isglobal) +def handleDiskMaxPartitionsExceeded(intf, device): + """ Ask user how to handle disk with too many partitions. + + Choices are to ignore the disk or to exit the installer. + + A return value of True indicates the user wants to continue with + installation without using this device. + """ + maxPartitionCount = device.partedDisk.maxPrimaryPartitionCount + \ + device.partedDisk.getMaxLogicalPartitions() + str = _("The drive %s has more than %d partitions on it," + "which is the maximum number of partitions for disk of " + "this type. You will not be able to make changes to the " + "partitioning of this disk or use any partitions beyond " + "%s%d in %s") % (device.path, maxPartitionCount, device.name, + maxPartitionCount, productName) + + rc = intf.messageWindow(_("Warning"), str, type="custom", + custom_buttons = [_("_Reboot"), _("_Ignore")], + custom_icon="warning") + if rc == 0: + sys.exit(0) + + return True + # Don't really know where to put this. def questionInitializeDisk(intf=None, name=None): retVal = False # The less destructive default @@ -1114,6 +1141,16 @@ class DeviceTree(object): self.addIgnoredDisk(name) return + # make sure the disk does not have more partitions than are supported + if device.mediaPresent: + maxPartitionCount = device.partedDisk.maxPrimaryPartitionCount + \ + device.partedDisk.getMaxLogicalPartitions() + + if len(device.partedDisk.partitions)> maxPartitionCount and \ + handleDiskMaxPartitionsExceeded(self.intf, device): + self.addIgnoredDisk(name) + return + self._addDevice(device) # If this is a mac-formatted disk we just initialized, make sure the diff --git a/storage/partitioning.py b/storage/partitioning.py index 8e9ab3c..f2c036f 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -697,6 +697,15 @@ def allocatePartitions(disks, partitions): # loop through disks for _disk in req_disks: disk = partedDisks[_disk.path] + + # check if we can allocate new partitions from this disk + max_parts = disk.maxPrimaryPartitionCount + \ + disk.getMaxLogicalPartitions() + if len(disk.partitions)>= max_parts: + log.debug("disk %s already has its maximum allowable number" + " of partitions (%d)" % (_disk.name, max_parts)) + continue + #for p in disk.partitions: # log.debug("disk %s: part %s" % (disk.device.path, p.path)) sectorSize = disk.device.physicalSectorSize
_______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list