summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table_mac.pm
diff options
context:
space:
mode:
authorMystery Man <unknown@mandriva.org>2000-11-08 00:01:16 +0000
committerMystery Man <unknown@mandriva.org>2000-11-08 00:01:16 +0000
commitd5c526273db473a7d87a26000585900fc10dda7d (patch)
tree0fdaabe7a00921b6cc556601b103d344fc7ac781 /perl-install/partition_table_mac.pm
parent9c164312d4bfff6d93e1c4529de6b992f2bebc44 (diff)
downloaddrakx-d5c526273db473a7d87a26000585900fc10dda7d.tar
drakx-d5c526273db473a7d87a26000585900fc10dda7d.tar.gz
drakx-d5c526273db473a7d87a26000585900fc10dda7d.tar.bz2
drakx-d5c526273db473a7d87a26000585900fc10dda7d.tar.xz
drakx-d5c526273db473a7d87a26000585900fc10dda7d.zip
This commit was manufactured by cvs2svn to create branch
'unlabeled-1.1.1'.
Diffstat (limited to 'perl-install/partition_table_mac.pm')
-rw-r--r--perl-install/partition_table_mac.pm75
1 files changed, 19 insertions, 56 deletions
diff --git a/perl-install/partition_table_mac.pm b/perl-install/partition_table_mac.pm
index 568e396b2..61e741f4b 100644
--- a/perl-install/partition_table_mac.pm
+++ b/perl-install/partition_table_mac.pm
@@ -76,15 +76,7 @@ my $pmagic = 0x504D;
sub adjustStart($$) {
my ($hd, $part) = @_;
- my $end = $part->{start} + $part->{size};
- my $partmap_end = $hd->{primary}{raw}[0]{size};
-
- if ($part->{start} <= $partmap_end) {
- $part->{start} = $partmap_end + 1;
- $part->{size} = $end - $part->{start};
- }
}
-
sub adjustEnd($$) {
my ($hd, $part) = @_;
}
@@ -102,8 +94,7 @@ sub read($$) {
foreach $i (0 .. $info{bzDrvrCnt}-1) {
sysread F, $tmp, psizeof($dd_format) or die "error while reading driver data in sector $sector";
- my %dd; @dd{@$dd_fields} = unpack $dd_format, $tmp;
- push @{$info{ddMap}}, \%dd;
+ $info{ddMap}[$i] = unpack $dd_format, $tmp;
}
#- check magic number
@@ -122,7 +113,7 @@ sub read($$) {
c::lseek_sector(fileno(F), $sector, 512) or die "reading of partition in sector $sector failed";
my @pt;
- for ($i=0;$i<$partmapsize;$i++) {
+ for($i=0;$i<$partmapsize;$i++) {
my $part;
sysread F, $part, psizeof($p_format) or die "error while reading partition info in sector $sector";
@@ -136,8 +127,7 @@ sub read($$) {
if ($h{pType} =~ /^Apple_UNIX_SVR2/i) {
$h{pName} =~ /swap/i ? ($h{type} = 0x82) : ($h{type} = 0x83);
} elsif ($h{pType} =~ /^Apple_Free/i) {
- next;
- #$h{type} = 0x0;
+ $h{type} = 0x0;
} elsif ($h{pType} =~ /^Apple_HFS/i) {
$h{type} = 0x402;
} elsif ($h{pType} =~ /^Apple_Partition_Map/i) {
@@ -146,12 +136,6 @@ sub read($$) {
} else {
$h{type} = 0x401;
};
-
- # Let's see if this partition is a driver.
- foreach (@{$info{ddMap}}) {
- $_->{ddBlock} == $h{pPBlockStart} and $h{isDriver} = 1;
- }
-
}
\%h;
} [ $part ];
@@ -181,12 +165,12 @@ sub write($$$;$) {
# Now go thru the partitions, sort and fill gaps.
my $last;
- while ($part) {
+ while($part) {
$last = $part;
$part = &partition_table::next($hd, $part);
$part or last;
- if ($last->{start} + $last->{size} < $part->{start}) {
+ if($last->{start} + $last->{size} < $part->{start}) {
#There is a gap between partitions. Fill it and move on.
push @partstowrite, {
type => 0x0,
@@ -198,7 +182,7 @@ sub write($$$;$) {
};
# now, fill a gap at the end if there is one.
- if ($last->{start} + $last->{size} < $hd->{totalsectors}) {
+ if($last->{start} + $last->{size} < $hd->{totalsectors}) {
push @partstowrite, {
type => 0x0,
start => $last->{start} + $last->{size},
@@ -207,16 +191,13 @@ sub write($$$;$) {
}
# Since we didn't create any new drivers, let's try and match up our driver records with out partitons and see if any are missing.
- $info->{bzDrvrCnt} = 0;
+ my $i;
my @ddstowrite;
- my $dd;
- foreach $dd (@{$info->{ddMap}}) {
- foreach (@partstowrite) {
- if ($dd->{ddBlock} == $_->{pPBlockStart}) {
- push @ddstowrite, $dd;
- $info->{bzDrvrCnt}++;
- last;
- }
+ foreach $i ( 0 .. $info->{bzDrvrCnt} - 1) {
+ my $ddBlock = $_->{ddBlock};
+ my $dd = $_;
+ foreach(@partstowrite) {
+ $ddBlock == $_->{pPBlockStart} and push @ddstowrite, $dd;
}
}
@@ -224,11 +205,11 @@ sub write($$$;$) {
syswrite F, pack($bz_format, @$info{@$bz_fields}), psizeof($bz_format) or return 0;
# ...and now the driver information.
- foreach (@ddstowrite) {
- syswrite F, pack($dd_format, @$_{@$dd_fields}), psizeof($dd_format) or return 0;
+ foreach $i ( 0 .. $info->{bzDrvrCnt} - 1) {
+ syswrite F, pack($dd_format, $ddstowrite[$i]{@$dd_fields}), psizeof($dd_format) or return 0;
}
# zero the rest of the data in the first block.
- foreach ( 1 .. (494 - ((@ddstowrite) * 8))) {
+ foreach $i ( 1 .. (494 - ($info->{bzDrvrCnt} * 8))) {
syswrite F, "\0", 1 or return 0;
}
#c::lseek_sector(fileno(F), $sector, 512) or return 0;
@@ -253,7 +234,7 @@ sub write($$$;$) {
$_->{pBootArgs} = "\0";
$_->{pReserved} = "\0";
- if ($_->{type} == 0x402) {
+ if($_->{type} == 0x402) {
$_->{pType} = "Apple_HFS";
$_->{pName} = "MacOS";
$_->{pFlags} = 0x4000037F;
@@ -304,36 +285,18 @@ sub info {
sub clear_raw {
my ($hd) = @_;
- my @oldraw = @{$hd->{primary}{raw}};
my $pt = { raw => [ ({}) x 63 ], info => info($hd) };
#- handle special case for partition 1 which is the partition map.
- $pt->{raw}[0] = {
+ my $part = {
type => 0x401,
start => 1,
size => 63,
isMap => 1,
};
-# $pt->{raw}[1] = {
-# type => 0x0,
-# start => 64,
-# size => $hd->{totalsectors} - 64,
-# isMap => 0,
-# };
- push @{$pt->{normal}}, $pt->{raw}[0];
-# push @{$pt->{normal}}, $pt->{raw}[1];
-
- #- Recover any Apple Drivers, if any.
- my $i = 1;
- foreach (@oldraw) {
- if (defined $_->{isDriver}) {
- $pt->{raw}[$i] = $_;
- push @{$pt->{normal}}, $pt->{raw}[$i];
- $i++;
- }
- };
- @{$pt->{info}{ddMap}} = @{$hd->{primary}{info}{ddMap}};
+ $pt->{raw}[0] = $part;
+ push @{$pt->{normal}}, $part;
$pt;
}