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

Michael Tautschnig mt at alioth.debian.org
Fri Sep 17 17:48:08 UTC 2010


Author: mt
Date: 2010-09-17 17:48:06 +0000 (Fri, 17 Sep 2010)
New Revision: 6058

Added:
   branches/experimental/patches/setup-storage_user-100-percent
Modified:
   branches/experimental/patches/series
Log:
Make 100% a valid size spec (previously, setup-storage would tell you to go away
because not all of the disk is useable (think MBR etc.); now 100% means 100% of
the usable disk space).


Modified: branches/experimental/patches/series
===================================================================
--- branches/experimental/patches/series	2010-09-17 17:04:13 UTC (rev 6057)
+++ branches/experimental/patches/series	2010-09-17 17:48:06 UTC (rev 6058)
@@ -11,3 +11,4 @@
 setup-storage_no-useless-rebuild
 setup-storage_preserve-format-all
 setup-storage_gpt-bios-fix
+setup-storage_user-100-percent

Added: branches/experimental/patches/setup-storage_user-100-percent
===================================================================
--- branches/experimental/patches/setup-storage_user-100-percent	                        (rev 0)
+++ branches/experimental/patches/setup-storage_user-100-percent	2010-09-17 17:48:06 UTC (rev 6058)
@@ -0,0 +1,107 @@
+2010-09-17  Michael Tautschnig  <mt at debian.org>
+
+	* setup-storage/Sizes.pm: A partition with size 100% will be as large as truly
+		feasible, not the size of the entire disk (MBR etc. aren't available to the
+		user).
+Index: trunk/lib/setup-storage/Sizes.pm
+===================================================================
+--- trunk.orig/lib/setup-storage/Sizes.pm
++++ trunk/lib/setup-storage/Sizes.pm	
+@@ -296,13 +296,14 @@
+ # @param $current_disk Current config of this disk
+ # @param $next_start Start of the next partition
+ # @param $min_req_total_space Minimum space required on disk
++# @param $max_avail The maximum size of a partition on this disk
+ #
+ # @return Updated values of ($next_start, $min_req_total_space)
+ #
+ ################################################################################
+ sub do_partition_preserve {
+ 
+-  my ($part_id, $config, $disk, $next_start, $min_req_total_space) = @_;
++  my ($part_id, $config, $disk, $next_start, $min_req_total_space, $max_avail) = @_;
+   # reference to the current disk config
+   my $current_disk = $FAI::current_config{$disk};
+ 
+@@ -321,8 +322,7 @@
+     and die "Previous partitions overflow begin of preserved partition $part_dev_name\n";
+ 
+   # get what the user desired
+-  my ($start, $end) = &FAI::make_range($part->{size}->{range},
+-    $current_disk->{size} . "B");
++  my ($start, $end) = &FAI::make_range($part->{size}->{range}, $max_avail);
+   ($start > $curr_part->{count_byte} || $end < $curr_part->{count_byte})
+     and warn "Preserved partition $part_dev_name retains size " .
+       $curr_part->{count_byte} . "B\n";
+@@ -433,6 +433,7 @@
+ # @param $current_disk Current config of this disk
+ # @param $next_start Start of the next partition
+ # @param $min_req_total_space Minimum space required on disk
++# @param $max_avail The maximum size of a partition on this disk
+ # @param $worklist Reference to the remaining partitions
+ #
+ # @return Updated values of ($next_start, $min_req_total_space)
+@@ -440,15 +441,14 @@
+ ################################################################################
+ sub do_partition_real {
+ 
+-  my ($part_id, $config, $disk, $next_start, $min_req_total_space, $worklist) = @_;
++  my ($part_id, $config, $disk, $next_start, $min_req_total_space, $max_avail, $worklist) = @_;
+   # reference to the current disk config
+   my $current_disk = $FAI::current_config{$disk};
+ 
+   # reference to the current partition
+   my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
+ 
+-  my ($start, $end) = &FAI::make_range($part->{size}->{range},
+-    $current_disk->{size} . "B");
++  my ($start, $end) = &FAI::make_range($part->{size}->{range}, $max_avail);
+ 
+   # check, whether the size is fixed
+   if ($end != $start) {
+@@ -487,8 +487,7 @@
+         next;
+       } else {
+         my ($min_size, $max_size) = &FAI::make_range(
+-          $FAI::configs{$config}{partitions}{$p}{size}{range},
+-          $current_disk->{size} . "B");
++          $FAI::configs{$config}{partitions}{$p}{size}{range}, $max_avail);
+ 
+         # logical partitions require the space for the EPBR to be left
+         # out
+@@ -630,6 +629,7 @@
+       # on msdos disk labels, the first partitions starts at head #1
+       $next_start = $current_disk->{bios_sectors_per_track} *
+         $current_disk->{sector_size};
++      $min_req_total_space += $next_start;
+ 
+     } elsif ($FAI::configs{$config}{disklabel} eq "gpt") {
+       # on GPT-EFI disk labels the first 34 and last 33 sectors must be left alone
+@@ -657,6 +657,11 @@
+       $min_req_total_space += 33 * $current_disk->{sector_size};
+     }
+ 
++    # the size of a 100% partition (the 100% available to the user)
++    my $max_avail = $current_disk->{size} - $min_req_total_space;
++    # expressed in bytes
++    $max_avail = "${max_avail}B";
++
+     # the list of partitions that we need to find start and end bytes for
+     my @worklist = (&numsort(keys %{ $FAI::configs{$config}{partitions} }));
+ 
+@@ -703,13 +708,13 @@
+       # 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);
++          $config, $disk, $next_start, $min_req_total_space, $max_avail);
+ 
+         # 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);
++          $config, $disk, $next_start, $min_req_total_space, $max_avail, \@worklist);
+ 
+         # msdos does not support partitions larger than 2TiB
+         ($part->{size}->{eff_size} > (&FAI::convert_unit("2TiB") * 1024.0 *




More information about the Fai-commit mailing list