[Fai-commit] r5813 - branches/experimental/patches

Michael Tautschnig mt at alioth.debian.org
Tue Jun 22 08:59:39 UTC 2010


Author: mt
Date: 2010-06-22 08:59:38 +0000 (Tue, 22 Jun 2010)
New Revision: 5813

Modified:
   branches/experimental/patches/setup-storage_better-parser-errors
   branches/experimental/patches/setup-storage_extended-is-not-last
Log:
Improved/fixed extended partition fixes


Modified: branches/experimental/patches/setup-storage_better-parser-errors
===================================================================
--- branches/experimental/patches/setup-storage_better-parser-errors	2010-06-20 14:10:29 UTC (rev 5812)
+++ branches/experimental/patches/setup-storage_better-parser-errors	2010-06-22 08:59:38 UTC (rev 5813)
@@ -2,11 +2,33 @@
 
 	* setup-storage/Parser.pm: Handle parse errors earlier for more informative
 		error messages.
+	* setup-storage/Volumes.pm: Proper error message in case an extended partition
+		is marked as preserve
 Index: trunk/lib/setup-storage/Parser.pm
 ===================================================================
 --- trunk.orig/lib/setup-storage/Parser.pm
 +++ trunk/lib/setup-storage/Parser.pm	
-@@ -354,7 +354,6 @@
+@@ -238,7 +238,7 @@
+ 
+       # msdos disk labels don't allow for more than 4 primary partitions
+       ($extended < 5)
+-        or die "Too many primary partitions while creating extended\n";
++        or die "Too many primary partitions; cannot add extended partition\n";
+ 
+       # initialize the entry, unless it already exists
+       defined ($FAI::configs{$FAI::device}{partitions}{$extended})
+@@ -246,6 +246,10 @@
+           size => {}
+         };
+ 
++      # as we can't compute the index from the reference, we need to store the
++      # $part_number explicitly
++      (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{number} = $extended;
++
+       my $part_size =
+         (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{size};
+ 
+@@ -354,7 +358,6 @@
          {
            $return = 1;
          }
@@ -14,7 +36,7 @@
  
      line: <skip: qr/[ \t]*/> "\\n"
          | <skip: qr/[ \t]*/> comment "\\n"
-@@ -420,6 +419,7 @@
+@@ -420,6 +423,7 @@
            &FAI::init_disk_config($item[ 1 ]);
          }
          option(s?)
@@ -22,7 +44,7 @@
  
      raid_option: /^preserve_always:(\d+(,\d+)*)/
          {
-@@ -643,6 +643,7 @@
+@@ -643,6 +647,7 @@
          }
          mountpoint tmpfs_size mount_options
          | type mountpoint size filesystem mount_options lv_or_fsopts
@@ -30,7 +52,7 @@
  
      type: 'primary'
          {
-@@ -714,7 +715,7 @@
+@@ -714,7 +719,7 @@
            1;
          }
  
@@ -39,3 +61,16 @@
          {
            # complete the size specification to be a range in all cases
            my $range = $1;
+Index: trunk/lib/setup-storage/Volumes.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Volumes.pm
++++ trunk/lib/setup-storage/Volumes.pm	
+@@ -520,6 +520,8 @@
+               defined($FAI::current_config{$1}{partitions}{$part_id})) ? 1 : 0)
+           if (2 == $part->{size}->{preserve});
+         next unless ($part->{size}->{preserve} || $part->{size}->{resize});
++        ($part->{size}->{extended}) and die
++          "Preserving extended partitions is not supported; mark all logical partitions instead\n";
+         defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
+           "Can't preserve ". &FAI::make_device_name($1, $part->{number})
+             . " because it does not exist\n";

Modified: branches/experimental/patches/setup-storage_extended-is-not-last
===================================================================
--- branches/experimental/patches/setup-storage_extended-is-not-last	2010-06-20 14:10:29 UTC (rev 5812)
+++ branches/experimental/patches/setup-storage_extended-is-not-last	2010-06-22 08:59:38 UTC (rev 5813)
@@ -25,7 +25,7 @@
    }
  
    # on gpt, ensure that the partition ends at a sector boundary
-@@ -686,17 +680,8 @@
+@@ -686,37 +680,45 @@
        # reference to the current partition
        my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
  
@@ -41,30 +41,41 @@
        # msdos specific: deal with extended partitions
 -      elsif ($part->{size}->{extended}) {
 +      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;
++        }
++
          # make sure that there is only one extended partition
-         ($extended == -1 || 1 == scalar (@worklist))
-           or &FAI::internal_error("More than 1 extended partition");
-@@ -705,18 +690,32 @@
+-        ($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
+-        # 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
-+        # worklist; also push all remaining primary partitions to the end
-         if (scalar (@worklist) > 1) {
+-        if (scalar (@worklist) > 1) {
 -          push @worklist, shift @worklist;
-+          my $has_logical = 0;
-+          foreach (@worklist) {
-+            $has_logical = 1 if ($_ > 4);
-+          }
-+          do {
-+            push @worklist, shift @worklist;
-+          } while ($has_logical && $worklist[0] < 5);
-           next;
-         }
- 
-+        ($part->{size}->{preserve}) and
-+          warn "Extended partition will be rebuilt instead of being preserved\n";
+-          next;
+-        }
+-
          # determine the size of the extended partition
          &FAI::do_partition_extended($part_id, $config, $current_disk);
  




More information about the Fai-commit mailing list