From 1799efb03565ab9c12bf0a7982f37a7413d47aba Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 17 Jan 2000 17:22:00 +0000 Subject: no_comment --- perl-install/partition_table_bsd.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'perl-install/partition_table_bsd.pm') 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; -- cgit v1.2.1