From 98654a20cbad80fc51a6a17cfa6f17ea2a0da93f Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Tue, 18 Sep 2007 10:49:42 +0000 Subject: simplify: read_one was used for primary and extended. replacing most of read_one() with read_primary() --- perl-install/partition_table.pm | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'perl-install/partition_table.pm') diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 08d9d5814..1d15d6ece 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -223,13 +223,12 @@ sub get_normal_parts_and_holes { grep { !isEmpty($_) || $_->{size} >= $hd->cylinder_size } @l; } -sub read_one($$) { - my ($hd, $sector) = @_; +sub read_primary { + my ($hd) = @_; my ($pt, $info); #- it can be safely considered that the first sector is used to probe the partition table #- but other sectors (typically for extended partition ones) have to match this type! - if (!$sector) { my @parttype = ( if_(arch() =~ /^ia64/, 'gpt'), arch() =~ /^sparc/ ? ('sun', 'bsd') : ('dos', 'bsd', 'sun', 'mac'), @@ -245,22 +244,17 @@ sub read_one($$) { # perl_checker: require partition_table::sun require "partition_table/$_.pm"; bless $hd, "partition_table::$_"; - ($pt, $info) = $hd->read_one($sector); - log::l("found a $_ partition table on $hd->{file} at sector $sector"); + ($pt, $info) = $hd->read_one(0); + log::l("found a $_ partition table on $hd->{file} at sector 0"); }; $@ or last; } - } else { - #- keep current blessed object for that, this means it is neccessary to read sector 0 before. - ($pt, $info) = $hd->read_one($sector); - } - partition_table::raw::pt_info_to_primary($hd, $pt, $info); } sub read { my ($hd) = @_; - my $pt = read_one($hd, 0) or return 0; + my $pt = read_primary($hd, 0) or return 0; $hd->{primary} = $pt; undef $hd->{extended}; verifyPrimary($pt); @@ -288,7 +282,10 @@ sub read { sub read_extended { my ($hd, $extended, $need_removing_empty_extended) = @_; - my $pt = read_one($hd, $extended->{start}) or return 0; + my $pt = do { + my ($pt, $info) = $hd->read_one($extended->{start}) or return 0; + partition_table::raw::pt_info_to_primary($hd, $pt, $info); + }; $pt = { %$extended, %$pt }; push @{$hd->{extended}}, $pt; -- cgit v1.2.1