summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table_bsd.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2000-01-27 22:15:55 +0000
committerPascal Rigaux <pixel@mandriva.com>2000-01-27 22:15:55 +0000
commitf5b6d853f3ed37cd88f4797f7bfb41fef7dd81ce (patch)
tree0e4db5f684c4e5dac4779c78a2ca90cf63aa5079 /perl-install/partition_table_bsd.pm
parentde9cfda6393333a5a9e69e666aa6f56b8971c16c (diff)
downloaddrakx-f5b6d853f3ed37cd88f4797f7bfb41fef7dd81ce.tar
drakx-f5b6d853f3ed37cd88f4797f7bfb41fef7dd81ce.tar.gz
drakx-f5b6d853f3ed37cd88f4797f7bfb41fef7dd81ce.tar.bz2
drakx-f5b6d853f3ed37cd88f4797f7bfb41fef7dd81ce.tar.xz
drakx-f5b6d853f3ed37cd88f4797f7bfb41fef7dd81ce.zip
no_comment
Diffstat (limited to 'perl-install/partition_table_bsd.pm')
-rw-r--r--perl-install/partition_table_bsd.pm28
1 files changed, 14 insertions, 14 deletions
diff --git a/perl-install/partition_table_bsd.pm b/perl-install/partition_table_bsd.pm
index 13398e007..a68d0ec4e 100644
--- a/perl-install/partition_table_bsd.pm
+++ b/perl-install/partition_table_bsd.pm
@@ -47,6 +47,8 @@ my ($main_format, $main_fields) = list2kv(
S => 'npartitions',
I => 'bbsize',
I => 'sbsize',
+ a128=> 'partitions',
+ a236=> 'blank',
);
$main_format = join '', @$main_format;
@@ -66,20 +68,18 @@ 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 $size = psizeof($format);
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;
+ my %h; @h{@fields} = unpack $format, $_;
$h{type} = $typeToDos{$h{type}} || $h{type};
\%h;
- } (1..$info{npartitions});
+ } $info{partitions} =~ /(.{$size})/g;
+
+ #- check magic number
+ $info{magic} == $magic or die "bad magic number";
+ $info{magic2} == $magic or die "bad magic number";
[ @pt ], \%info;
}
@@ -103,13 +103,13 @@ sub write($$$;$) {
$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";
- foreach (@$pt) {
+ $info->{partitions} = join '', map {
local $_->{type} = $typeFromDos{$_->{type}} || $_->{type};
- syswrite F, pack($format, @$_{@fields}), psizeof($format) or return 0;
- }
+ pack $format, @$_{@fields};
+ } @$pt;
+
+ syswrite F, pack($main_format, @$info{@$main_fields}), psizeof($main_format) or return 0;
1;
}