diff options
Diffstat (limited to 'perl-install/partition_table/raw.pm')
-rw-r--r-- | perl-install/partition_table/raw.pm | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm index 09a0137e7..7b4e7d5cf 100644 --- a/perl-install/partition_table/raw.pm +++ b/perl-install/partition_table/raw.pm @@ -1,4 +1,4 @@ -package partition_table::raw; # $Id: raw.pm 266069 2010-02-09 19:47:35Z pterjan $ +package partition_table::raw; use diagnostics; use strict; @@ -11,10 +11,6 @@ use log; use c; my @MBR_signatures = ( -if_(arch() =~ /ppc/, - (map { [ 'yaboot', 0, "PM", 0x200 * $_ + 0x10, "bootstrap\0" ] } 0 .. 61), #- "PM" is a Partition Map - [ 'yaboot', 0x400, "BD", 0x424, "\011bootstrap" ], #- "BD" is a HFS filesystem -), [ 'empty', 0, "\0\0\0\0" ], [ 'grub', 0, "\xEBG", 0x17d, "stage1 \0" ], [ 'grub', 0, "\xEBH", 0x17e, "stage1 \0" ], @@ -29,6 +25,14 @@ if_(arch() =~ /ppc/, substr($tmp, 0, 2) eq "\xEBH" or return; index($tmp, $magic, $min) >= 0 && "grub"; }, + sub { my ($F) = @_; + #- similar to grub-legacy, grub2 doesn't seem to have good magic + #- so scanning a range of possible places where grub can have its string + my ($min, $max, $magic) = (0x176, 0x188, "GRUB"); + my $tmp; + sysseek($F, 0, 0) && sysread($F, $tmp, $max + length($magic)) or return; + index($tmp, $magic, $min) >= 0 && "grub2"; + }, [ 'lilo', 0x2, "LILO" ], [ 'lilo', 0x6, "LILO" ], [ 'lilo', 0x6 + 0x40, "LILO" ], #- when relocated in lilo's bsect_update(), variable "space" on paragraph boundary gives 0x40 @@ -73,20 +77,9 @@ sub last_usable_sector { sub max_partition_start { 1e99 } sub max_partition_size { 1e99 } -#- default method for starting a partition, only head size or twice -#- is allowed for starting a partition after a cylinder boundarie. -sub adjustStart($$) { - my ($hd, $part) = @_; - my $end = $part->{start} + $part->{size}; +#- default method for starting a partition +sub adjustStart($$) {} - if (cylinder_size($hd)) { - $part->{start} = round_up($part->{start}, - $part->{start} % cylinder_size($hd) < 2 * $hd->{geom}{sectors} ? - $hd->{geom}{sectors} : cylinder_size($hd)); - $part->{size} = $end - $part->{start}; - $part->{size} > 0 or die "adjustStart get a too small partition to handle correctly"; - } -} #- adjusting end to match a cylinder boundary, two methods are used and must #- match at the end, else something is wrong and nothing will be done on #- partition table. @@ -133,7 +126,7 @@ sub get_geometries { $geom{start} = 1; compute_nb_cylinders(\%geom, $total); $geom{totalcylinders} = $geom{cylinders}; - log::l("Fake geometry on ".$_->{file}.": heads=$geom{heads} sectors=$geom{sectors} cylinders=$geom{cylinders} start=$geom{start}"); + log::l("Fake geometry on " . $_->{file} . ": heads=$geom{heads} sectors=$geom{sectors} cylinders=$geom{cylinders} start=$geom{start}"); add2hash_($_, { totalsectors => $total, geom => \%geom }); 1; } elsif (my $h = get_geometry($_->{file})) { @@ -248,7 +241,8 @@ sub zero_MBR_and_dirty { sub read_primary { my ($hd) = @_; - my ($pt, $info) = eval { $hd->read_one(0) } or return; + my ($pt, $info) = eval { $hd->read_one(0) }; + $pt or return; my $primary = partition_table::raw::pt_info_to_primary($hd, $pt, $info); $hd->{primary} = $primary; undef $hd->{extended}; @@ -296,7 +290,7 @@ sub test_for_bad_drives { my $tmp2; &$seek; sysread $F, $tmp2, $SECTORSIZE or die "test_for_bad_drives: cannot even read again ($!)"; $tmp eq $tmp2 or die -N("Something bad is happening on your drive. +N("Something bad is happening on your hard disk drive. A test to check the integrity of data has failed. It means writing anything on the disk will end up with random, corrupted data."); } |