summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table_bsd.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/partition_table_bsd.pm')
-rw-r--r--perl-install/partition_table_bsd.pm36
1 files changed, 12 insertions, 24 deletions
diff --git a/perl-install/partition_table_bsd.pm b/perl-install/partition_table_bsd.pm
index a68d0ec4e..0b03249c1 100644
--- a/perl-install/partition_table_bsd.pm
+++ b/perl-install/partition_table_bsd.pm
@@ -47,8 +47,6 @@ my ($main_format, $main_fields) = list2kv(
S => 'npartitions',
I => 'bbsize',
I => 'sbsize',
- a128=> 'partitions',
- a236=> 'blank',
);
$main_format = join '', @$main_format;
@@ -68,14 +66,12 @@ 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;
- #- TODO verify checksum
-
- my $size = psizeof($format);
my @pt = map {
- my %h; @h{@fields} = unpack $format, $_;
+ 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;
- } $info{partitions} =~ /(.{$size})/g;
+ } (1..$nb_primary);
#- check magic number
$info{magic} == $magic or die "bad magic number";
@@ -89,27 +85,19 @@ sub read($$) {
sub write($$$;$) {
my ($hd, $sector, $pt, $info) = @_;
- #- handle testing for writing partition table on file only!
- local *F;
- if ($::testing) {
- my $file = "/tmp/partition_table_$hd->{device}";
- open F, ">$file" or die "error opening test file $file";
- } else {
- 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
+ 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;
$info->{npartitions} = $nb_primary; #- is it ok?
+ syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
+
@$pt == $nb_primary or die "partition table does not have $nb_primary entries";
- $info->{partitions} = join '', map {
+ foreach (@$pt) {
local $_->{type} = $typeFromDos{$_->{type}} || $_->{type};
- pack $format, @$_{@fields};
- } @$pt;
-
- syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
+ syswrite F, pack($format, @$_{@fields}), psizeof($format) or return 0;
+ }
1;
}
@@ -124,7 +112,7 @@ sub info {
dtype => $hd->{device} =~ /^sd/ ? $dtype_scsi : $dtype_ST506,
secsize => $common::SECTORSIZE,
ncylinders => $hd->{geom}{cylinders},
- secpercyl => $hd->cylinder_size(),
+ secpercyl => partition_table::cylinder_size($hd),
secprtunit => $hd->{geom}{totalsectors},
rpm => 3600,
interleave => 1,