[Fai-commit] r6400 - trunk/lib/setup-storage
Michael Tautschnig
mt at alioth.debian.org
Fri Apr 15 12:38:42 UTC 2011
Author: mt
Date: 2011-04-15 12:38:39 +0000 (Fri, 15 Apr 2011)
New Revision: 6400
Modified:
trunk/lib/setup-storage/Sizes.pm
Log:
setup-storage/Sizes.pm: Make 100% a valid partition size.
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).
Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm 2011-04-15 12:38:18 UTC (rev 6399)
+++ trunk/lib/setup-storage/Sizes.pm 2011-04-15 12:38:39 UTC (rev 6400)
@@ -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
@@ -646,6 +645,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;
# the MBR requires space, too
$min_req_total_space += $current_disk->{bios_sectors_per_track} *
@@ -698,6 +698,11 @@
$FAI::partition_pointer->{mountpoint} = "-";
}
+ # 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} }));
@@ -749,13 +754,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