[Fai-commit] r6329 - trunk/lib/setup-storage

Michael Tautschnig mt at alioth.debian.org
Thu Apr 14 10:56:19 UTC 2011


Author: mt
Date: 2011-04-14 10:56:17 +0000 (Thu, 14 Apr 2011)
New Revision: 6329

Modified:
   trunk/lib/setup-storage/Sizes.pm
Log:
setup-storage/Sizes.pm: Properly handle extended partitions that aren't the last primary partition.


Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm	2011-04-14 10:41:18 UTC (rev 6328)
+++ trunk/lib/setup-storage/Sizes.pm	2011-04-14 10:56:17 UTC (rev 6329)
@@ -362,15 +362,9 @@
     ($part->{size}->{extended} == $curr_part->{is_extended})
       or die "Preserved partition $part_dev_name can't change extended/normal setting\n";
 
-    # extended partitions consume no space
-    if ($part->{size}->{extended}) {
-
-      # revert the addition of the size
-      $min_req_total_space -= $part->{size}->{eff_size};
-
-      # set the next start to the start of the extended partition
-      $next_start = $part->{start_byte};
-    }
+    # extended partitions are not handled in here (anymore)
+    ($part->{size}->{extended})
+      and die &FAI::internal_error("Preserve must not handle extended partitions\n");
   }
 
   # on gpt, ensure that the partition ends at a sector boundary
@@ -708,37 +702,45 @@
       # reference to the current partition
       my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
 
-      # the partition $part_id must be preserved
-      if ($part->{size}->{preserve}) {
-        ($next_start, $min_req_total_space) = &FAI::do_partition_preserve($part_id, 
-          $config, $disk, $next_start, $min_req_total_space);
+      # msdos specific: deal with extended partitions
+      if ($part->{size}->{extended}) {
+        # handle logical partitions first
+        if (scalar (@worklist) > 1) {
+          my @old_worklist = @worklist;
+          @worklist = ();
+          my @primaries = ();
+          foreach my $p (@old_worklist) {
+            if ($p > 4) {
+              push @worklist, $p;
+            } else {
+              push @primaries, $p;
+            }
+          }
+          if (scalar (@worklist)) {
+            push @worklist, @primaries;
+            next;
+          }
+          @worklist = @primaries;
+        }
 
-        # partition done
-        shift @worklist;
-      }
-
-      # msdos specific: deal with extended partitions
-      elsif ($part->{size}->{extended}) {
         # make sure that there is only one extended partition
-        ($extended == -1 || 1 == scalar (@worklist))
-          or &FAI::internal_error("More than 1 extended partition");
+        ($extended == -1) or &FAI::internal_error("More than 1 extended partition");
 
         # set the local variable to this id
         $extended = $part_id;
 
-        # the size cannot be determined now, push it to the end of the
-        # worklist; the check against $extended being == -1 ensures that
-        # there is no indefinite loop
-        if (scalar (@worklist) > 1) {
-          push @worklist, shift @worklist;
-          next;
-        }
-
         # determine the size of the extended partition
         &FAI::do_partition_extended($part_id, $config, $current_disk);
 
         # partition done
         shift @worklist;
+      # the partition $part_id must be preserved
+      } elsif ($part->{size}->{preserve}) {
+        ($next_start, $min_req_total_space) = &FAI::do_partition_preserve($part_id,
+          $config, $disk, $next_start, $min_req_total_space);
+
+        # partition done
+        shift @worklist;
       } else {
         ($next_start, $min_req_total_space) = &FAI::do_partition_real($part_id, 
           $config, $disk, $next_start, $min_req_total_space, \@worklist);




More information about the Fai-commit mailing list