From a00c3995a27103b97534c3957dff9441874fd9ce Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 20 Jun 2005 06:02:14 +0000 Subject: ignore HDIO_GETGEO fail (useful for dmraid) --- perl-install/partition_table/raw.pm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'perl-install/partition_table') diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm index c290258f5..0887915c7 100644 --- a/perl-install/partition_table/raw.pm +++ b/perl-install/partition_table/raw.pm @@ -149,22 +149,25 @@ sub get_geometries { sub get_geometry { my ($dev) = @_; - my $g = ""; - sysopen(my $F, $dev, 0) or return; - ioctl($F, c::HDIO_GETGEO(), $g) or return; - my %geom; @geom{qw(heads sectors cylinders start)} = unpack "CCSL", $g; - $geom{totalcylinders} = $geom{cylinders}; - - my $total; - #- $geom{cylinders} is no good (only a ushort, that means less than 2^16 => at best 512MB) - if ($total = c::total_sectors(fileno $F)) { - compute_nb_cylinders(\%geom, $total); - } else { - $total = $geom{heads} * $geom{sectors} * $geom{cylinders}; + + my $total = c::total_sectors(fileno $F); + + my $g = ""; + my %geom; + if (ioctl($F, c::HDIO_GETGEO(), $g)) { + @geom{qw(heads sectors cylinders start)} = unpack "CCSL", $g; + $geom{totalcylinders} = $geom{cylinders}; + + #- $geom{cylinders} is no good (only a ushort, that means less than 2^16 => at best 512MB) + if ($total) { + compute_nb_cylinders(\%geom, $total); + } else { + $total = $geom{heads} * $geom{sectors} * $geom{cylinders}; + } } - { geom => \%geom, totalsectors => $total }; + { totalsectors => $total, if_($geom{heads}, geom => \%geom) }; } sub openit { -- cgit v1.2.1