From 4bbec5f4c46fee4ad7160edd35a486c10d90be42 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Wed, 29 Sep 2004 03:26:38 +0000 Subject: don't die when failing to open a device (to get its geometry), skip it instead (as used to be done before partition_table::raw::get_geometries() was introduced) --- perl-install/fsedit.pm | 2 +- perl-install/partition_table/raw.pm | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index c3d46d332..42404bfe8 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -109,7 +109,7 @@ sub get_hds { $hd->{prefix} ||= $hd->{device}; } - partition_table::raw::get_geometries(\@drives); + @drives = partition_table::raw::get_geometries(@drives); my (@hds, @raw_hds); foreach my $hd (@drives) { diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm index 59ca08906..4ed615b2a 100644 --- a/perl-install/partition_table/raw.pm +++ b/perl-install/partition_table/raw.pm @@ -101,22 +101,27 @@ sub keep_non_duplicates { } sub get_geometries { - my ($hds) = @_; + my (@hds) = @_; - foreach my $hd (@$hds) { - my $h = get_geometry($hd->{file}) or log::l("An error occurred while getting the geometry of block device $hd->{file}: $!"), next; - add2hash_($hd, $h); - } + @hds = grep { + if (my $h = get_geometry($_->{file})) { + add2hash_($_, $h); + 1; + } else { + log::l("An error occurred while getting the geometry of block device $_->{file}: $!"); + 0; + } + } @hds; my %id2hd = keep_non_duplicates(map { - my $F = openit($_) or die "failed to open device $_->{device}"; + my $F = openit($_) or log::l("failed to open device $_->{device}"); my $tmp; - if (c::lseek_sector(fileno($F), 0, 0x1b8) && sysread($F, $tmp, 4)) { + if ($F && c::lseek_sector(fileno($F), 0, 0x1b8) && sysread($F, $tmp, 4)) { [ sprintf('0x%08x', unpack('V', $tmp)), $_ ]; } else { (); } - } @$hds); + } @hds); my %id2edd = keep_non_duplicates(map { [ chomp_(cat_("$_/mbr_signature")), $_ ] } glob("/sys/firmware/edd/int13_dev*")); @@ -136,6 +141,8 @@ sub get_geometries { $hd->{geom} = $geom if $geom; } } + + @hds; } sub get_geometry { -- cgit v1.2.1