[PATCH 28/30] Add a slice when the extended partition contains "free space"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* iw/partition_gui.py (_createStripe): We add a "free space" sliece to
the extended partition when the last offset of the last logical
parition is less then the end of the extended partition.
---
 iw/partition_gui.py |   49 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 43 insertions(+), 6 deletions(-)

diff --git a/iw/partition_gui.py b/iw/partition_gui.py
index a9547f2..11cc76f 100644
--- a/iw/partition_gui.py
+++ b/iw/partition_gui.py
@@ -337,42 +337,64 @@ class DiskStripeGraph(StripeGraph):
                 drive.size, drive.model)
         stripe = Stripe(self.getCanvas(), drivetext, self.editCB, obj = drive)
 
+        # Free Extended Calculation
+        # Free slice/partition in the extended partition "free space".  If there
+        # is space between the last logical partition and the ending of the 
+        # extended partition we create a "free space" in the extended part.
         # Create the slices.
+
+        # These offsets are where the partition/slices end. 0<offset<1
+        last_logical_offset = None
+        last_extended_offset = None
+
         for part in drive.format.partedDisk.getFreeSpacePartitions() \
                 + [d for d in drive.format.partitions]:
             if part.getSize(unit="MB") <= 1.0:
                 continue
 
+            # Create the start and length for the slice.
+            xoffset = float(part.geometry.start) \
+                    / float(drive.partedDevice.length)
+            xlength = float(part.geometry.length) \
+                    / float(drive.partedDevice.length)
+
             if part.type == parted.PARTITION_LOGICAL:
                 partstr = "%s\n%s MB" % (part.path, part.getSize())
                 stype = Slice.SUBSLICE
                 unsel_col = self.part_type_colors["unsel_logical"]
                 sel_col = self.part_type_colors["sel_logical"]
+
+                # Free Extended Calculation
+                if last_logical_offset == None:
+                    last_logical_offset = xoffset + xlength
+                elif last_logical_offset < xoffset + xlength:
+                    last_logical_offset = xoffset + xlength
+
             elif part.type == parted.PARTITION_FREESPACE:
                 partstr = "%s\n%s MB" % (_("Free"), part.getSize())
                 stype = Slice.SLICE
                 unsel_col = self.part_type_colors["unsel_freespace"]
                 sel_col = self.part_type_colors["sel_freespace"]
+
             elif part.type == parted.PARTITION_EXTENDED:
                 partstr = ""
                 stype = Slice.CONTAINERSLICE
                 unsel_col = self.part_type_colors["unsel_extended"]
                 sel_col = self.part_type_colors["sel_extended"]
+
+                # Free Extended Calculation
+                last_extended_offset = xoffset + xlength
+
             elif part.type == parted.PARTITION_NORMAL:
                 partstr = "%s\n%s MB" % (part.path, part.getSize())
                 stype = Slice.SLICE
                 unsel_col = self.part_type_colors["unsel_normal"]
                 sel_col = self.part_type_colors["sel_normal"]
+
             else:
                 # We don't really want to draw anything in this case.
                 continue
 
-            # Create the start and length for the slice.
-            xoffset = float(part.geometry.start) \
-                    / float(drive.partedDevice.length)
-            xlength = float(part.geometry.length) \
-                    / float(drive.partedDevice.length)
-
             # We need to use the self.storage objects not the partedDisk ones.
             # The free space has not storage object.
             if part.type != parted.PARTITION_FREESPACE:
@@ -390,6 +412,21 @@ class DiskStripeGraph(StripeGraph):
                     unsel_col = unsel_col, obj = o_part)
             stripe.addSlice(slice)
 
+        # Free Extended Calculation
+        if (last_logical_offset != None and last_extended_offset != None) \
+                and last_logical_offset < last_extended_offset:
+            # We must create a "free extended" slice
+            stype = Slice.SUBSLICE
+            unsel_col = self.part_type_colors["unsel_freespace"]
+            sel_col = self.part_type_colors["sel_freespace"]
+            xoffset = last_logical_offset
+            xlength = last_extended_offset - last_logical_offset
+            slcstr = "%s\n%s MB" % (_("Free"), drive.size * xlength)
+
+            slice = Slice(stripe, slcstr, stype, xoffset, xlength,
+                    sel_col=sel_col, unsel_col=unsel_col)
+            stripe.addSlice(slice)
+
         return stripe
 
 class LVMStripeGraph(StripeGraph):
-- 
1.6.4.2

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux