[Fai-commit] r6705 - trunk/lib/setup-storage
Michael Tautschnig
mt at alioth.debian.org
Sat Oct 22 12:37:34 UTC 2011
Author: mt
Date: 2011-10-22 12:37:34 +0000 (Sat, 22 Oct 2011)
New Revision: 6705
Modified:
trunk/lib/setup-storage/Sizes.pm
trunk/lib/setup-storage/Volumes.pm
Log:
setup-storage/{Volumes,Sizes}.pm: keep current_config consistent
* setup-storage/{Volumes,Sizes}.pm: Do not unintentionally create entries in
current_config and properly test before using it (user may have missed to
add the disks to $disklist).
Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm 2011-10-22 12:35:53 UTC (rev 6704)
+++ trunk/lib/setup-storage/Sizes.pm 2011-10-22 12:37:34 UTC (rev 6705)
@@ -584,6 +584,8 @@
# test, whether $disk is a block special device
(-b $disk) or die "$disk is not a valid device name\n";
# reference to the current disk config
+ defined ($FAI::current_config{$disk}) or
+ &FAI::internal_error("Device $disk missing in \$disklist - check buggy");
my $current_disk = $FAI::current_config{$disk};
# align to sector boundary by default
Modified: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk/lib/setup-storage/Volumes.pm 2011-10-22 12:35:53 UTC (rev 6704)
+++ trunk/lib/setup-storage/Volumes.pm 2011-10-22 12:37:34 UTC (rev 6705)
@@ -506,12 +506,14 @@
if (1 == $i_p_d) {
if (defined($FAI::configs{"PHY_$disk"}) &&
defined($FAI::configs{"PHY_$disk"}{partitions}{$part_no})) {
- defined ($FAI::current_config{$disk}{partitions}{$part_no}) or die
+ (defined ($FAI::current_config{$disk}) &&
+ defined ($FAI::current_config{$disk}{partitions}{$part_no})) or die
"Can't preserve $device_name because it does not exist\n";
$FAI::configs{"PHY_$disk"}{partitions}{$part_no}{size}{preserve} = 1;
$FAI::configs{"PHY_$disk"}{preserveparts} = 1;
} elsif (0 == $missing) {
- defined ($FAI::current_config{$disk}{partitions}{$part_no}) or die
+ (defined ($FAI::current_config{$disk}) &&
+ defined ($FAI::current_config{$disk}{partitions}{$part_no})) or die
"Can't preserve $device_name because it does not exist\n";
}
} elsif ($device_name =~ m{^/dev/md[\/]?(\d+)$}) {
@@ -562,21 +564,20 @@
foreach my $config (keys %FAI::configs) {
if ($config =~ /^PHY_(.+)$/) {
+ defined ($FAI::current_config{$1}) or
+ die "Device $1 was not specified in \$disklist\n";
+ defined ($FAI::current_config{$1}{partitions}) or
+ &FAI::internal_error("Missing key \"partitions\"");
+
foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
$part->{size}->{preserve} =
- ((defined($FAI::current_config{$1}) &&
- defined($FAI::current_config{$1}{partitions}{$part_id})) ? 1 : 0)
+ (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";
- if (0 == $part_id) {
- defined ($FAI::current_config{$1}) or die
- "Can't preserve $1 because it does not exist\n";
- } else {
- defined ($FAI::current_config{$1}) or die
- "Can't preserve partition on $1 because $1 does not exist\n";
+ if (0 != $part_id) {
defined ($FAI::current_config{$1}{partitions}{$part_id}) or die
"Can't preserve ". &FAI::make_device_name($1, $part_id)
. " because it does not exist\n";
More information about the Fai-commit
mailing list