diff options
author | David Cantrell <dcantrell@redhat.com> | 2009-02-02 20:17:06 -1000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2009-02-12 11:30:40 -1000 |
commit | 4b85d666335df77c09bb51f6208d041221937f4f (patch) | |
tree | ca19baa8a83be81c8c12aa09784f7ec772588d2f | |
parent | 00c375b0fc6bbf0b0b3920c141c43bd59895961f (diff) | |
download | anaconda-4b85d666335df77c09bb51f6208d041221937f4f.tar.gz anaconda-4b85d666335df77c09bb51f6208d041221937f4f.tar.xz anaconda-4b85d666335df77c09bb51f6208d041221937f4f.zip |
Iterate over partitions to see free space.
Use the getFirstPartition() and nextPartition() method to
iterate over partitions so we can see the free space as
represented by libparted.
-rw-r--r-- | autopart.py | 22 | ||||
-rw-r--r-- | iw/partition_gui.py | 8 | ||||
-rw-r--r-- | partitions.py | 6 |
3 files changed, 22 insertions, 14 deletions
diff --git a/autopart.py b/autopart.py index 6a70896f2..d6db49481 100644 --- a/autopart.py +++ b/autopart.py @@ -114,9 +114,11 @@ def bootAlphaCheckRequirements(part): # The first free space should start at the begining of the drive # and span for a megabyte or more. - for free in disk.partitions: + free = disk.getFirstPartition() + while free: if free.type & parted.PARTITION_FREESPACE: break + free = free.nextPartition() if (not free or free.geometry.start != 1L or free.getSize(unit="MB") < 1): return BOOTALPHA_NO_RESERVED_SPACE @@ -148,10 +150,7 @@ def findFreespace(diskset): free = {} for drive in diskset.disks.keys(): disk = diskset.disks[drive] - free[drive] = [] - for part in disk.partitions: - if part.type & parted.PARTITION_FREESPACE: - free[drive].append(part) + free[drive] = disk.getFreeSpacePartitions() return free @@ -453,13 +452,12 @@ def fitSized(diskset, requests, primOnly = 0, newParts = None): # now need to update freespace since adding extended # took some space found = 0 - for part in disk.partitions: - if part.type & parted.PARTITION_FREESPACE: - if part.geometry.start > freeStartSec and part.geometry.end <= freeEndSec: - found = 1 - freeStartSec = part.geometry.start - freeEndSec = part.geometry.end - break + for part in disk.getFreeSpacePartitions(): + if part.geometry.start > freeStartSec and part.geometry.end <= freeEndSec: + found = 1 + freeStartSec = part.geometry.start + freeEndSec = part.geometry.end + break if not found: raise PartitioningError, "Could not find free space after making new extended partition" diff --git a/iw/partition_gui.py b/iw/partition_gui.py index abb2845c9..79555beda 100644 --- a/iw/partition_gui.py +++ b/iw/partition_gui.py @@ -828,12 +828,15 @@ class PartitionWindow(InstallWindow): sectorsPerCyl = heads * sectors extendedParent = None - for part in disk.partitions: + part = disk.getFirstPartition() + while part: if part.type & parted.PARTITION_METADATA: + part = part.nextPartition() continue # ignore the tiny < 1 MB partitions (#119479) if part.getSize(unit="MB") <= 1.0: if not part.is_active() or not part.getFlag(parted.PARTITION_BOOT): + part = part.nextPartition() continue stripe.add(part) @@ -898,6 +901,7 @@ class PartitionWindow(InstallWindow): else: self.tree.appendToHiddenPartitionsList(part) self.tree.remove(iter) + part = part.nextPartition() continue else: self.tree[iter]['Mount Point'] = "" @@ -945,6 +949,8 @@ class PartitionWindow(InstallWindow): self.tree[iter]['Size (MB)'] = sizestr self.tree[iter]['PyObject'] = part + part = part.nextPartition() + canvas = self.diskStripeGraph.getCanvas() apply(canvas.set_scroll_region, canvas.root().get_bounds()) self.treeView.expand_all() diff --git a/partitions.py b/partitions.py index d6fc6fdb8..dd036481b 100644 --- a/partitions.py +++ b/partitions.py @@ -370,8 +370,10 @@ class Partitions: drives.sort() for drive in drives: disk = diskset.disks[drive] - for part in disk.partitions: + part = disk.getFirstPartition() + while part: if part.type & parted.PARTITION_METADATA: + part = part.nextPartition() continue format = None @@ -438,6 +440,8 @@ class Partitions: spec.fslabel = labels[mappedDev] self.addRequest(spec) + part = part.nextPartition() + # now we need to read in all pre-existing RAID stuff diskset.startMPath() diskset.startDmRaid() |