diff options
Diffstat (limited to 'perl-install/partition_table/bsd.pm')
-rw-r--r-- | perl-install/partition_table/bsd.pm | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm index e6af4e997..ec2a2edf4 100644 --- a/perl-install/partition_table/bsd.pm +++ b/perl-install/partition_table/bsd.pm @@ -1,4 +1,4 @@ -package partition_table::bsd; # $Id$ +package partition_table::bsd; use diagnostics; use strict; @@ -12,11 +12,11 @@ use partition_table; use c; #- very bad and rough handling :( -my %typeToDos = ( +my %pt_typeToDos = ( 8 => 0x83, 1 => 0x82, ); -my %typeFromDos = reverse %typeToDos; +my %pt_typeFromDos = reverse %pt_typeToDos; my ($main_format, $main_fields) = list2kv( I => 'magic', @@ -52,13 +52,16 @@ my ($main_format, $main_fields) = list2kv( ); $main_format = join '', @$main_format; -my @fields = qw(size start fsize type frag cpg); +my @fields = qw(size start fsize pt_type frag cpg); my $format = "I I I C C S"; my $magic = 0x82564557; my $nb_primary = 8; my $offset = 0x40; -sub read($$) { + +sub use_pt_type { 1 } + +sub read_one { my ($hd, $sector) = @_; my $tmp; @@ -73,7 +76,7 @@ sub read($$) { my $size = psizeof($format); my @pt = map { my %h; @h{@fields} = unpack $format, $_; - $h{type} = $typeToDos{$h{type}} || $h{type}; + fs::type::set_pt_type(\%h, $pt_typeToDos{$h{pt_type}} || $h{pt_type}); \%h; } $info{partitions} =~ /(.{$size})/g; @@ -85,9 +88,9 @@ sub read($$) { } # write the partition table (and extended ones) -# for each entry, it uses fields: start, size, type, active +# for each entry, it uses fields: start, size, pt_type, active sub write($$$;$) { - my ($hd, $sector, $pt, $info) = @_; + my ($hd, $_handle, $sector, $pt, $info) = @_; #- handle testing for writing partition table on file only! my $F; @@ -105,7 +108,7 @@ sub write($$$;$) { @$pt == $nb_primary or die "partition table does not have $nb_primary entries"; $info->{partitions} = join '', map { - local $_->{type} = $typeFromDos{$_->{type}} || $_->{type}; + local $_->{pt_type} = $pt_typeFromDos{$_->{pt_type}} || $_->{pt_type}; pack $format, @$_{@fields}; } @$pt; @@ -137,9 +140,10 @@ sub info { }; } -sub clear_raw { - my ($hd) = @_; - { raw => [ ({}) x $nb_primary ], info => info($hd) }; +sub initialize { + my ($class, $hd) = @_; + $hd->{primary} = { raw => [ ({}) x $nb_primary ], info => info($hd) }; + bless $hd, $class; } sub first_usable_sector { 2048 } |