diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2000-07-24 10:26:06 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2000-07-24 10:26:06 +0000 |
commit | 3cf3e2f2afd279dad95082ee81f3f83516024b27 (patch) | |
tree | 1d73d53ac3deaae5ae2f8c12f5d501e8ffa7f28e | |
parent | d97b226e3049c136401416aaceaba39587cd0605 (diff) | |
download | drakx-backup-do-not-use-3cf3e2f2afd279dad95082ee81f3f83516024b27.tar drakx-backup-do-not-use-3cf3e2f2afd279dad95082ee81f3f83516024b27.tar.gz drakx-backup-do-not-use-3cf3e2f2afd279dad95082ee81f3f83516024b27.tar.bz2 drakx-backup-do-not-use-3cf3e2f2afd279dad95082ee81f3f83516024b27.tar.xz drakx-backup-do-not-use-3cf3e2f2afd279dad95082ee81f3f83516024b27.zip |
no_comment
-rw-r--r-- | perl-install/partition_table.pm | 9 | ||||
-rw-r--r-- | perl-install/partition_table_empty.pm | 38 | ||||
-rw-r--r-- | perl-install/partition_table_raw.pm | 7 |
3 files changed, 43 insertions, 11 deletions
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index 0ea3fad13..03a3c9624 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -13,6 +13,7 @@ use Data::Dumper; use common qw(:common :system :functional); +use partition_table_empty; use partition_table_raw; use partition_table_dos; use partition_table_bsd; @@ -371,18 +372,12 @@ sub read_one($$) { my ($pt, $info); #- SUN bioses may blank disk or refuse to load it if the partition is unknown. my @parttype = arch() =~ /^sparc/ ? ('sun', 'bsd', 'unknown') : ('dos', 'bsd', 'sun', 'mac', 'unknown'); - foreach (@parttype) { + foreach ('empty', @parttype) { /unknown/ and die "unknown partition table format"; eval { bless $hd, "partition_table_$_"; ($pt, $info) = $hd->read($sector); log::l("found a $_ partition table on $hd->{file}"); - { - foreach my $e (@$pt) { - my $logtext = join(" ", map { "$_=$e->{$_}" } keys %$e); - log::l("$logtext"); - } - } }; $@ or last; } diff --git a/perl-install/partition_table_empty.pm b/perl-install/partition_table_empty.pm new file mode 100644 index 000000000..d59cea52b --- /dev/null +++ b/perl-install/partition_table_empty.pm @@ -0,0 +1,38 @@ +package partition_table_empty; + +#- this is a mainly dummy partition table. If we find it's empty, we just call - +#- zero_MBR which will take care of bless'ing us to the partition table type best +#- suited + + +use diagnostics; +use strict; +use vars qw(@ISA); + +@ISA = qw(partition_table_raw); + +use common qw(:common :system :file); +use partition_table_raw; +use partition_table; +use c; + + +sub read($$) { + my ($hd, $sector) = @_; + my $tmp; + + my $magic = "\0" x 256; + + local *F; partition_table_raw::openit($hd, *F) or die "failed to open device"; + c::lseek_sector(fileno(F), $sector, 0) or die "reading of partition in sector $sector failed"; + + #- check magic number + sysread F, $tmp, length $magic or die "error reading magic number"; + $tmp eq $magic or die "bad magic number"; + + partition_table_raw::zero_MBR($hd); + + $hd->{primary}{raw}; +} + +1; diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm index 7b886a1f8..4fe3fe73b 100644 --- a/perl-install/partition_table_raw.pm +++ b/perl-install/partition_table_raw.pm @@ -104,10 +104,9 @@ sub kernel_read($) { sub zero_MBR($) { my ($hd) = @_; -# unless (ref($hd) =~ /partition_table/) { - my $type = arch() eq "alpha" ? "bsd" : arch() =~ /^sparc/ ? "sun" : arch() eq "ppc" ? "mac" : "dos"; - bless $hd, "partition_table_$type"; -# } + #- force the standard partition type for the architecture + my $type = arch() eq "alpha" ? "bsd" : arch() =~ /^sparc/ ? "sun" : arch() eq "ppc" ? "mac" : "dos"; + bless $hd, "partition_table_$type"; $hd->{isDirty} = $hd->{needKernelReread} = 1; $hd->{primary} = $hd->clear_raw(); delete $hd->{extended}; |