summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-01-17 17:22:00 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-01-17 17:22:00 +0000
commit1799efb03565ab9c12bf0a7982f37a7413d47aba (patch)
tree834aedaa8843e95afbfa44e97079a6a0d7d569a8 /perl-install
parent39be5039adbec64a10ae686c35bc93ec5f3fca60 (diff)
downloaddrakx-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar
drakx-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar.gz
drakx-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar.bz2
drakx-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar.xz
drakx-1799efb03565ab9c12bf0a7982f37a7413d47aba.zip
no_comment
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/common.pm2
-rw-r--r--perl-install/partition_table.pm9
-rw-r--r--perl-install/partition_table_bsd.pm17
-rw-r--r--perl-install/partition_table_raw.pm2
4 files changed, 19 insertions, 11 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm
index d6c602487..d6b9220c8 100644
--- a/perl-install/common.pm
+++ b/perl-install/common.pm
@@ -136,7 +136,7 @@ sub grep_each(&%) {
while (($::a, $::b) = each %h) { $l{$::a} = $::b if &$f($::a, $::b) }
%l;
}
-sub list2kv { [ grep_index { even($::i) } @_ ], [ grep_index { odd($::i) } @_ ] }
+sub list2kv(@) { [ grep_index { even($::i) } @_ ], [ grep_index { odd($::i) } @_ ] }
#- pseudo-array-hash :)
sub map_tab_hash(&$@) {
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index 3bf6506bc..50abce97c 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -14,6 +14,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @important_types @fields2save);
use common qw(:common :system :functional);
use partition_table_dos;
use partition_table_bsd;
+use partition_table_sun;
use Data::Dumper;
@@ -231,7 +232,7 @@ sub verifyParts($) {
}
sub verifyPrimary($) {
my ($pt) = @_;
- $_->{start} > 0 || die "partition must NOT start at sector 0" foreach @{$pt->{normal}};
+ $_->{start} > 0 || arch() eq "sparc" || die "partition must NOT start at sector 0" foreach @{$pt->{normal}};
verifyParts_(@{$pt->{normal}}, $pt->{extended});
}
@@ -328,7 +329,8 @@ sub read_one($$) {
my ($hd, $sector) = @_;
my ($pt, $info);
- foreach ('dos', 'bsd') {
+ foreach ('dos', 'bsd', 'sun', 'unknown') {
+ /unknown/ and die "unknown partition table format";
eval {
bless $hd, "partition_table_$_";
($pt, $info) = $hd->read($sector);
@@ -337,7 +339,8 @@ sub read_one($$) {
$@ or last;
}
- my @extended = grep { isExtended($_) } @$pt;
+
+ my @extended = $hd->hasExtended ? grep { isExtended($_) } @$pt : ();
my @normal = grep { $_->{size} && $_->{type} && !isExtended($_) } @$pt;
@extended > 1 and die "more than one extended partition";
diff --git a/perl-install/partition_table_bsd.pm b/perl-install/partition_table_bsd.pm
index 0b03249c1..f3134f4fb 100644
--- a/perl-install/partition_table_bsd.pm
+++ b/perl-install/partition_table_bsd.pm
@@ -66,16 +66,20 @@ sub read($$) {
sysread F, $tmp, psizeof($main_format) or die "error while reading partition table in sector $sector";
my %info; @info{@$main_fields} = unpack $main_format, $tmp;
+ $info{npartitions} <= $nb_primary or die "too many partitions ($info{npartitions} > $nb_primary) for a bsd disklabel";
+
+ #- check magic number
+ $info{magic} == $magic or die "bad magic number";
+ $info{magic2} == $magic or die "bad magic number";
+
+ #- TODO verify checksum
+
my @pt = map {
sysread F, $tmp, psizeof($format) or die "error while reading partition table in sector $sector";
my %h; @h{@fields} = unpack $format, $tmp;
$h{type} = $typeToDos{$h{type}} || $h{type};
\%h;
- } (1..$nb_primary);
-
- #- check magic number
- $info{magic} == $magic or die "bad magic number";
- $info{magic2} == $magic or die "bad magic number";
+ } (1..$info{npartitions});
[ @pt ], \%info;
}
@@ -85,10 +89,11 @@ sub read($$) {
sub write($$$;$) {
my ($hd, $sector, $pt, $info) = @_;
- print "Her\n";
local *F; partition_table_raw::openit($hd, *F, 2) or die "error opening device $hd->{device} for writing";
c::lseek_sector(fileno(F), $sector, $offset) or return 0;
+ #- TODO compute checksum
+
$info->{npartitions} = $nb_primary; #- is it ok?
syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
diff --git a/perl-install/partition_table_raw.pm b/perl-install/partition_table_raw.pm
index 35287e965..39277bf39 100644
--- a/perl-install/partition_table_raw.pm
+++ b/perl-install/partition_table_raw.pm
@@ -55,7 +55,7 @@ sub kernel_read($) {
sub zero_MBR($) {
my ($hd) = @_;
# unless (ref($hd) =~ /partition_table/) {
- my $type = arch() eq "alpha" ? "bsd" : "dos";
+ my $type = arch() eq "alpha" ? "bsd" : arch() eq "sparc" ? "sun" : "dos";
bless $hd, "partition_table_$type";
# }
$hd->{isDirty} = $hd->{needKernelReread} = 1;