diff options
Diffstat (limited to 'perl-install/partition_table/mac.pm')
| -rw-r--r-- | perl-install/partition_table/mac.pm | 48 |
1 files changed, 26 insertions, 22 deletions
diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm index 219b6434d..78e5469cd 100644 --- a/perl-install/partition_table/mac.pm +++ b/perl-install/partition_table/mac.pm @@ -1,12 +1,13 @@ -package partition_table::mac; # $Id$ +package partition_table::mac; use diagnostics; #use strict; - fixed other PPC code to comply, but program bails on empty partition table - sbenedict -use vars qw(@ISA $freepart $bootstrap_part $macos_part); +use vars qw(@ISA $freepart $bootstrap_part $macos_part $new_bootstrap); @ISA = qw(partition_table::raw); use common; +use fs::type; use partition_table::raw; use partition_table; use c; @@ -78,6 +79,8 @@ $p_format = join '', @$p_format; my $magic = 0x4552; my $pmagic = 0x504D; +sub use_pt_type { 1 } + sub first_usable_sector { 1 } sub adjustStart($$) { @@ -95,7 +98,7 @@ sub adjustEnd($$) { my ($_hd, $_part) = @_; } -sub read($$) { +sub read_one { my ($hd, $sector) = @_; my $tmp; @@ -139,7 +142,7 @@ sub read($$) { $h{start} = ($h{pPBlockStart} * $info{bzBlkSize}) / 512; if ($h{pType} =~ /^Apple_UNIX_SVR2/i) { - $h{pName} =~ /swap/i ? ($h{pt_type} = 0x82) : ($h{pt_type} = 0x83); + $h{fs_type} = $h{pName} =~ /swap/i ? 'swap' : 'ext2'; } elsif ($h{pType} =~ /^Apple_Free/i) { #- need to locate a 1MB partition to setup a bootstrap on if ($freepart && $freepart->{size} >= 1) { @@ -151,7 +154,7 @@ sub read($$) { $h{pt_type} = 0x0; $h{pName} = 'Extra'; } elsif ($h{pType} =~ /^Apple_HFS/i) { - $h{pt_type} = 0x402; + fs::type::set_pt_type(\%h, 0x402); if (defined $macos_part) { #- swag at identifying MacOS - 1st HFS partition } else { @@ -174,7 +177,7 @@ sub read($$) { } else { $h{pt_type} = 0x401; $h{isDriver} = 1; - }; + } # Let's see if this partition is a driver. foreach (@{$info{ddMap}}) { @@ -184,13 +187,13 @@ sub read($$) { } \%h; } [ $part ]; - }; + } [ @pt ], \%info; } sub write($$$;$) { - my ($hd, $sector, $pt, $info) = @_; + my ($hd, $_handle, $sector, $pt, $info) = @_; #- handle testing for writing partition table on file only! my $F; @@ -224,7 +227,7 @@ sub write($$$;$) { }; } push @partstowrite, $part; - }; + } # now, fill a gap at the end if there is one. if ($last->{start} + $last->{size} < $hd->{totalsectors}) { @@ -235,7 +238,7 @@ 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. + # Since we did not 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 @ddstowrite; foreach my $dd (@{$info->{ddMap}}) { @@ -295,29 +298,29 @@ sub write($$$;$) { $_->{pFlags} = 0x33; $_->{isBoot} = 1; log::l("writing a bootstrap at /dev/$_->{device}"); - $install_steps_interactive::new_bootstrap = 1 if !(defined $partition_table::mac::bootstrap_part); + $new_bootstrap = 1 if !(defined $bootstrap_part); $bootstrap_part = "/dev/" . $_->{device}; - } elsif ($_->{pt_type} == 0x82) { + } elsif (isSwap($_)) { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "swap"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x83) { + } elsif ($_->{fs_type} eq 'ext2') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux Native"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x183) { + } elsif ($_->{fs_type} eq 'reiserfs') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux ReiserFS"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x283) { + } elsif ($_->{fs_type} eq 'xfs') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux XFS"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x383) { + } elsif ($_->{fs_type} eq 'jfs') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux JFS"; $_->{pFlags} = 0x33; - } elsif ($_->{pt_type} == 0x483) { + } elsif ($_->{fs_type} eq 'ext3') { $_->{pType} = "Apple_UNIX_SVR2"; $_->{pName} = "Linux ext3"; $_->{pFlags} = 0x33; @@ -326,7 +329,7 @@ sub write($$$;$) { $_->{pName} = "Extra"; $_->{pFlags} = 0x31; } - }; + } $_->{pMapEntry} = @partstowrite; syswrite $F, pack($p_format, @$_{@$p_fields}), psizeof($p_format) or return 0; } @@ -354,8 +357,8 @@ sub info { $info; } -sub clear_raw { - my ($hd) = @_; +sub initialize { + my ($class, $hd) = @_; my @oldraw = @{$hd->{primary}{raw}}; my $pt = { raw => [ ({}) x 63 ], info => info($hd) }; @@ -383,10 +386,11 @@ sub clear_raw { push @{$pt->{normal}}, $pt->{raw}[$i]; $i++; } - }; + } @{$pt->{info}{ddMap}} = @{$hd->{primary}{info}{ddMap}}; - $pt; + $hd->{primary} = $pt; + bless $hd, $class; } 1; |
