summaryrefslogtreecommitdiffstats
path: root/perl-install/partition_table
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-07-05 07:47:36 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-07-05 07:47:36 +0000
commit0a23f36bd52f14f68cc394c37ef7a9af0c406caa (patch)
tree96cf9a72f416f0c2175055e43e1fbe2e3918ef1b /perl-install/partition_table
parent51fd51c2f560620d0e5c73a824d7677661f9c385 (diff)
downloaddrakx-0a23f36bd52f14f68cc394c37ef7a9af0c406caa.tar
drakx-0a23f36bd52f14f68cc394c37ef7a9af0c406caa.tar.gz
drakx-0a23f36bd52f14f68cc394c37ef7a9af0c406caa.tar.bz2
drakx-0a23f36bd52f14f68cc394c37ef7a9af0c406caa.tar.xz
drakx-0a23f36bd52f14f68cc394c37ef7a9af0c406caa.zip
big renaming of field {type} to {pt_type},
this will allow defining {fs_type} which will always be a string whereas {pt_type} will always be a number
Diffstat (limited to 'perl-install/partition_table')
-rw-r--r--perl-install/partition_table/bsd.pm12
-rw-r--r--perl-install/partition_table/dos.pm10
-rw-r--r--perl-install/partition_table/gpt.pm16
-rw-r--r--perl-install/partition_table/mac.pm40
-rw-r--r--perl-install/partition_table/raw.pm4
-rw-r--r--perl-install/partition_table/sun.pm16
6 files changed, 49 insertions, 49 deletions
diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm
index e6af4e997..cdf18e6d1 100644
--- a/perl-install/partition_table/bsd.pm
+++ b/perl-install/partition_table/bsd.pm
@@ -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,7 +52,7 @@ 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;
@@ -73,7 +73,7 @@ sub read($$) {
my $size = psizeof($format);
my @pt = map {
my %h; @h{@fields} = unpack $format, $_;
- $h{type} = $typeToDos{$h{type}} || $h{type};
+ $h{pt_type} = $pt_typeToDos{$h{pt_type}} || $h{pt_type};
\%h;
} $info{partitions} =~ /(.{$size})/g;
@@ -85,7 +85,7 @@ 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) = @_;
@@ -105,7 +105,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;
diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm
index 86f2c0256..38cdf60ed 100644
--- a/perl-install/partition_table/dos.pm
+++ b/perl-install/partition_table/dos.pm
@@ -11,7 +11,7 @@ use partition_table::raw;
use partition_table;
use c;
-my @fields = qw(active start_head start_sec start_cyl type end_head end_sec end_cyl start size);
+my @fields = qw(active start_head start_sec start_cyl pt_type end_head end_sec end_cyl start size);
my $format = "C8 V2";
my $magic = "\x55\xAA";
my $nb_primary = 4;
@@ -52,7 +52,7 @@ sub compute_CHS {
sub CHS_from_part_rawCHS {
my ($part) = @_;
- $part->{start} || $part->{type} or return;
+ $part->{start} || $part->{pt_type} or return;
my ($raw_chs_start, $raw_chs_end) = get_rawCHS($part);
rawCHS2CHS($raw_chs_start), rawCHS2CHS($raw_chs_end);
@@ -61,7 +61,7 @@ sub CHS_from_part_rawCHS {
sub CHS_from_part_linear {
my ($geom, $part) = @_;
- $part->{start} || $part->{type} or return;
+ $part->{start} || $part->{pt_type} or return;
sector2CHS($geom, $part->{start}), sector2CHS($geom, $part->{start} + $part->{size} - 1);
}
@@ -197,7 +197,7 @@ 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) = @_;
@@ -215,7 +215,7 @@ sub write($$$;$) {
foreach (@$pt) {
compute_CHS($hd, $_);
local $_->{start} = $_->{local_start} || 0;
- $_->{active} ||= 0; $_->{type} ||= 0; $_->{size} ||= 0; #- for no warning
+ $_->{active} ||= 0; $_->{pt_type} ||= 0; $_->{size} ||= 0; #- for no warning
syswrite $F, pack($format, @$_{@fields}), psizeof($format) or return 0;
}
syswrite $F, $magic, length $magic or return 0;
diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm
index bb1cb82a4..2f1506bbd 100644
--- a/perl-install/partition_table/gpt.pm
+++ b/perl-install/partition_table/gpt.pm
@@ -130,8 +130,8 @@ sub read_partitionEntries {
sysread $F, $tmp, psizeof($partitionEntry_format) or die "error while reading partition table in sector $info->{partitionEntriesLBA}";
my %h; @h{@$partitionEntry_fields} = unpack $partitionEntry_format, $tmp;
$h{size} = $h{ending} - $h{start} + 1;
- $h{type} = $gpt_types_rev{$h{gpt_type}};
- $h{type} = 0x100 if !defined $h{type};
+ $h{pt_type} = $gpt_types_rev{$h{gpt_type}};
+ $h{pt_type} = 0x100 if !defined $h{pt_type};
\%h;
} (1 .. $info->{nbPartitions});
\@pt;
@@ -141,9 +141,9 @@ sub read {
my ($hd, $sector) = @_;
my $l = partition_table::dos::read($hd, $sector);
- my @l = grep { $_->{size} && $_->{type} && !partition_table::isExtended($_) } @$l;
+ my @l = grep { $_->{size} && $_->{pt_type} && !partition_table::isExtended($_) } @$l;
@l == 1 or die "bad PMBR";
- $l[0]{type} == 0xee or die "bad PMBR";
+ $l[0]{pt_type} == 0xee or die "bad PMBR";
my $myLBA = $l[0]{start};
my $F = partition_table::raw::openit($hd) or die "failed to open device";
@@ -159,14 +159,14 @@ 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) = @_;
foreach (@$pt) {
$_->{ending} = $_->{start} + $_->{size} - 1;
$_->{guid} ||= generate_guid();
- $_->{gpt_type} = $gpt_types{$_->{type}} || $_->{gpt_type} || $gpt_types{0x83};
+ $_->{gpt_type} = $gpt_types{$_->{pt_type}} || $_->{gpt_type} || $gpt_types{0x83};
}
my $partitionEntries = join('', map {
pack($partitionEntry_format, @$_{@$partitionEntry_fields})
@@ -184,7 +184,7 @@ sub write {
{
# write the PMBR
my $pmbr = partition_table::dos::clear_raw();
- $pmbr->{raw}[0] = { type => 0xee, local_start => $info->{myLBA}, size => $info->{alternateLBA} - $info->{myLBA} + 1 };
+ $pmbr->{raw}[0] = { pt_type => 0xee, local_start => $info->{myLBA}, size => $info->{alternateLBA} - $info->{myLBA} + 1 };
partition_table::dos::write($hd, $sector, $pmbr->{raw});
}
@@ -210,7 +210,7 @@ sub write {
sub raw_removed {
my ($_hd, $raw) = @_;
- @$raw = grep { $_->{size} && $_->{type} } @$raw;
+ @$raw = grep { $_->{size} && $_->{pt_type} } @$raw;
}
sub can_raw_add {
my ($hd) = @_;
diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm
index 2a8fe8df5..219b6434d 100644
--- a/perl-install/partition_table/mac.pm
+++ b/perl-install/partition_table/mac.pm
@@ -139,7 +139,7 @@ sub read($$) {
$h{start} = ($h{pPBlockStart} * $info{bzBlkSize}) / 512;
if ($h{pType} =~ /^Apple_UNIX_SVR2/i) {
- $h{pName} =~ /swap/i ? ($h{type} = 0x82) : ($h{type} = 0x83);
+ $h{pName} =~ /swap/i ? ($h{pt_type} = 0x82) : ($h{pt_type} = 0x83);
} elsif ($h{pType} =~ /^Apple_Free/i) {
#- need to locate a 1MB partition to setup a bootstrap on
if ($freepart && $freepart->{size} >= 1) {
@@ -148,10 +148,10 @@ sub read($$) {
$freepart = { start => $h{start}, size => $h{size}/2048, hd => $hd, part => "/dev/$hd->{device}" . ($i+1) };
log::l("free apple partition found on drive /dev/$freepart->{hd}{device}, block $freepart->{start}, size $freepart->{size}");
}
- $h{type} = 0x0;
+ $h{pt_type} = 0x0;
$h{pName} = 'Extra';
} elsif ($h{pType} =~ /^Apple_HFS/i) {
- $h{type} = 0x402;
+ $h{pt_type} = 0x402;
if (defined $macos_part) {
#- swag at identifying MacOS - 1st HFS partition
} else {
@@ -159,10 +159,10 @@ sub read($$) {
log::l("found MacOS at partition $macos_part");
}
} elsif ($h{pType} =~ /^Apple_Partition_Map/i) {
- $h{type} = 0x401;
+ $h{pt_type} = 0x401;
$h{isMap} = 1;
} elsif ($h{pType} =~ /^Apple_Bootstrap/i) {
- $h{type} = 0x401;
+ $h{pt_type} = 0x401;
$h{isBoot} = 1;
if (defined $bootstrap_part) {
#found a bootstrap already - use it, but log the find
@@ -172,7 +172,7 @@ sub read($$) {
log::l("found apple bootstrap at partition $bootstrap_part");
}
} else {
- $h{type} = 0x401;
+ $h{pt_type} = 0x401;
$h{isDriver} = 1;
};
@@ -218,7 +218,7 @@ sub write($$$;$) {
if ($last->{start} + $last->{size} < $part->{start}) {
#There is a gap between partitions. Fill it and move on.
push @partstowrite, {
- type => 0x0,
+ pt_type => 0x0,
start => $last->{start} + $last->{size},
size => $part->{start} - ($last->{start} + $last->{size}),
};
@@ -229,7 +229,7 @@ sub write($$$;$) {
# now, fill a gap at the end if there is one.
if ($last->{start} + $last->{size} < $hd->{totalsectors}) {
push @partstowrite, {
- type => 0x0,
+ pt_type => 0x0,
start => $last->{start} + $last->{size},
size => $hd->{totalsectors} - ($last->{start} + $last->{size}),
};
@@ -281,15 +281,15 @@ sub write($$$;$) {
$_->{pBootArgs} = "\0";
$_->{pReserved} = "\0";
- if ($_->{type} == 0x402) {
+ if ($_->{pt_type} == 0x402) {
$_->{pType} = "Apple_HFS";
$_->{pName} = "MacOS";
$_->{pFlags} = 0x4000037F;
- } elsif ($_->{type} == 0x401 && $_->{start} == 1) {
+ } elsif ($_->{pt_type} == 0x401 && $_->{start} == 1) {
$_->{pType} = "Apple_Partition_Map";
$_->{pName} = "Apple";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x401) {
+ } elsif ($_->{pt_type} == 0x401) {
$_->{pType} = "Apple_Bootstrap";
$_->{pName} = "bootstrap";
$_->{pFlags} = 0x33;
@@ -297,31 +297,31 @@ sub write($$$;$) {
log::l("writing a bootstrap at /dev/$_->{device}");
$install_steps_interactive::new_bootstrap = 1 if !(defined $partition_table::mac::bootstrap_part);
$bootstrap_part = "/dev/" . $_->{device};
- } elsif ($_->{type} == 0x82) {
+ } elsif ($_->{pt_type} == 0x82) {
$_->{pType} = "Apple_UNIX_SVR2";
$_->{pName} = "swap";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x83) {
+ } elsif ($_->{pt_type} == 0x83) {
$_->{pType} = "Apple_UNIX_SVR2";
$_->{pName} = "Linux Native";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x183) {
+ } elsif ($_->{pt_type} == 0x183) {
$_->{pType} = "Apple_UNIX_SVR2";
$_->{pName} = "Linux ReiserFS";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x283) {
+ } elsif ($_->{pt_type} == 0x283) {
$_->{pType} = "Apple_UNIX_SVR2";
$_->{pName} = "Linux XFS";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x383) {
+ } elsif ($_->{pt_type} == 0x383) {
$_->{pType} = "Apple_UNIX_SVR2";
$_->{pName} = "Linux JFS";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x483) {
+ } elsif ($_->{pt_type} == 0x483) {
$_->{pType} = "Apple_UNIX_SVR2";
$_->{pName} = "Linux ext3";
$_->{pFlags} = 0x33;
- } elsif ($_->{type} == 0x0) {
+ } elsif ($_->{pt_type} == 0x0) {
$_->{pType} = "Apple_Free";
$_->{pName} = "Extra";
$_->{pFlags} = 0x31;
@@ -361,13 +361,13 @@ sub clear_raw {
#- handle special case for partition 1 which is the partition map.
$pt->{raw}[0] = {
- type => 0x401,
+ pt_type => 0x401,
start => 1,
size => 63,
isMap => 1,
};
# $pt->{raw}[1] = {
-# type => 0x0,
+# pt_type => 0x0,
# start => 64,
# size => $hd->{totalsectors} - 64,
# isMap => 0,
diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm
index e01f9c1c3..8cbe0ec14 100644
--- a/perl-install/partition_table/raw.pm
+++ b/perl-install/partition_table/raw.pm
@@ -124,14 +124,14 @@ sub raw_removed {
}
sub can_raw_add {
my ($hd) = @_;
- $_->{size} || $_->{type} or return 1 foreach @{$hd->{primary}{raw}};
+ $_->{size} || $_->{pt_type} or return 1 foreach @{$hd->{primary}{raw}};
0;
}
sub raw_add {
my ($_hd, $raw, $part) = @_;
foreach (@$raw) {
- $_->{size} || $_->{type} and next;
+ $_->{size} || $_->{pt_type} and next;
$_ = $part;
return;
}
diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm
index 951a4b471..7c8a6beb9 100644
--- a/perl-install/partition_table/sun.pm
+++ b/perl-install/partition_table/sun.pm
@@ -32,7 +32,7 @@ my ($main_format, $main_fields) = list2kv(
);
$main_format = join '', @$main_format;
-my ($fields1, $fields2) = ([ qw(type flags) ], [ qw(start_cylinder size) ]);
+my ($fields1, $fields2) = ([ qw(pt_type flags) ], [ qw(start_cylinder size) ]);
my ($format1, $format2) = ("xCxC", "N2");
my $magic = 0xDABE;
my $nb_primary = 8;
@@ -92,10 +92,10 @@ sub read($$) {
my @infos_up = unpack $format1 x $nb_primary, $info{infos};
my @partitions_up = unpack $format2 x $nb_primary, $info{partitions};
foreach (0..$nb_primary-1) {
- my $h = { type => $infos_up[2 * $_], flag => $infos_up[1 + 2 * $_],
+ my $h = { pt_type => $infos_up[2 * $_], flag => $infos_up[1 + 2 * $_],
start_cylinder => $partitions_up[2 * $_], size => $partitions_up[1 + 2 * $_] };
$h->{start} = $sector + $h->{start_cylinder} * $hd->cylinder_size;
- $h->{type} && $h->{size} or $h->{$_} = 0 foreach keys %$h;
+ $h->{pt_type} && $h->{size} or $h->{$_} = 0 foreach keys %$h;
push @pt, $h;
}
@@ -105,7 +105,7 @@ sub read($$) {
# @h{@$fields1} = unpack $format1, $_[0];
# @h{@$fields2} = unpack $format2, $_[1];
# $h{start} = $sector + $h{start_cylinder} * $hd->cylinder_size();
-# $h{type} && $h{size} or $h{$_} = 0 foreach keys %h;
+# $h{pt_type} && $h{size} or $h{$_} = 0 foreach keys %h;
# \%h;
# } [ grep { $_ } split /(.{$size1})/o, $info{infos} ], [ grep { $_ } split /(.{$size2})/o, $info{partitions} ];
@@ -113,7 +113,7 @@ 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 ($csize, $wdsize) = (0, 0);
@@ -130,8 +130,8 @@ sub write($$$;$) {
($info->{infos}, $info->{partitions}) = map { join '', @$_ } list2kv map {
$_->{start} % $hd->cylinder_size == 0 or die "partition not at beginning of cylinder";
-# $csize += $_->{size} if $_->{type} != 5;
-# $wdsize += $_->{size} if $_->{type} == 5;
+# $csize += $_->{size} if $_->{pt_type} != 5;
+# $wdsize += $_->{size} if $_->{pt_type} == 5;
$_->{flags} |= 0x10 if $_->{mntpoint} eq '/';
$_->{flags} |= 0x01 if partition_table::isSwap($_);
local $_->{start_cylinder} = $_->{start} / $hd->cylinder_size - $sector;
@@ -188,7 +188,7 @@ sub clear_raw {
#- handle special case for partition 2 which is whole disk.
$pt->{raw}[2] = {
- type => 5, #- the whole disk type.
+ pt_type => 5, #- the whole disk type.
flags => 0,
start_cylinder => 0,
size => $hd->{geom}{cylinders} * $hd->cylinder_size,