summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table_bsd.pm
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/partition_table_bsd.pm
parent39be5039adbec64a10ae686c35bc93ec5f3fca60 (diff)
downloaddrakx-backup-do-not-use-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar
drakx-backup-do-not-use-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar.gz
drakx-backup-do-not-use-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar.bz2
drakx-backup-do-not-use-1799efb03565ab9c12bf0a7982f37a7413d47aba.tar.xz
drakx-backup-do-not-use-1799efb03565ab9c12bf0a7982f37a7413d47aba.zip
no_comment
Diffstat (limited to 'perl-install/partition_table_bsd.pm')
-rw-r--r--perl-install/partition_table_bsd.pm17
1 files changed, 11 insertions, 6 deletions
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;