Package: fai-client
Version: 3.2.11
Severity: important
Tags: patch

If preserving a partition is requested, but the disk_config requires creating an
extended partition with the to-be-preserved partition id, the partition will be
lost. The attached patch fixes this.

Best,
Michael

2008-10-10  Michael Tautschnig  <[EMAIL PROTECTED]>

        * lib/setup-storage/Parser.pm, lib/setup-storage/Sizes.pm: Warn, if a
                preserved partition does not match the size specified in the 
disk_config;
                fail, if an extended partition is to be created in place of a
                to-be-preserved partition
Index: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk.orig/lib/setup-storage/Parser.pm
+++ trunk/lib/setup-storage/Parser.pm   
@@ -217,10 +217,11 @@
       ($extended < 5)
         or die "Too many primary partitions while creating extended\n";
 
-      # initialize the entry
-      (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended} = {
-        size => {}
-      };
+      # initialize the entry, unless it already exists
+      defined ($FAI::configs{$FAI::device}{partitions}{$extended})
+        or (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended} = {
+          size => {}
+        };
 
       my $part_size =
         (\%FAI::configs)->{$FAI::device}->{partitions}->{$extended}->{size};
Index: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk.orig/lib/setup-storage/Sizes.pm
+++ trunk/lib/setup-storage/Sizes.pm    
@@ -294,6 +294,13 @@
   ($next_start > $curr_part->{begin_byte})
     and die "Previous partitions overflow begin of preserved partition 
$part_id\n";
 
+  # get what the user desired
+  my ($start, $end) = &FAI::make_range($part->{size}->{range},
+    $current_disk->{size} . "B");
+  ($start > $curr_part->{count_byte} || $end < $curr_part->{count_byte})
+    and warn "Preserved partition $part_id retains size " .
+      $curr_part->{count_byte} . "\n";
+
   # set the effective size to the value known already
   $part->{size}->{eff_size} = $curr_part->{count_byte};
 
@@ -321,6 +328,11 @@
     $min_req_total_space += $current_disk->{bios_sectors_per_track} *
       $current_disk->{sector_size} if ($part_id > 4);
 
+    # make sure we don't change extended partitions to ordinary ones and
+    # vice-versa
+    ($part->{size}->{extended} == $curr_part->{is_extended})
+      or die "Preserved partition $part_id can't change extended/normal 
setting\n";
+
     # extended partitions consume no space
     if ($part->{size}->{extended}) {
 

Attachment: pgpoJJz8cmcLo.pgp
Description: PGP signature

Reply via email to