From 0a23f36bd52f14f68cc394c37ef7a9af0c406caa Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Mon, 5 Jul 2004 07:47:36 +0000 Subject: 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 --- perl-install/any.pm | 2 +- perl-install/bootloader.pm | 2 +- perl-install/diskdrake/dav.pm | 2 +- perl-install/diskdrake/hd_gtk.pm | 24 ++++----- perl-install/diskdrake/interactive.pm | 70 ++++++++++++------------ perl-install/diskdrake/removable.pm | 6 +-- perl-install/fs.pm | 60 ++++++++++----------- perl-install/fsedit.pm | 90 +++++++++++++++---------------- perl-install/install_any.pm | 12 +++-- perl-install/install_interactive.pm | 4 +- perl-install/install_steps.pm | 6 +-- perl-install/install_steps_interactive.pm | 2 +- perl-install/lvm.pm | 4 +- perl-install/network/smbnfs.pm | 4 +- perl-install/partition_table.pm | 67 +++++++++++------------ perl-install/partition_table/bsd.pm | 12 ++--- perl-install/partition_table/dos.pm | 10 ++-- perl-install/partition_table/gpt.pm | 16 +++--- perl-install/partition_table/mac.pm | 40 +++++++------- perl-install/partition_table/raw.pm | 4 +- perl-install/partition_table/sun.pm | 16 +++--- perl-install/raid.pm | 2 +- 22 files changed, 231 insertions(+), 224 deletions(-) diff --git a/perl-install/any.pm b/perl-install/any.pm index 68d76e52b..67d540631 100644 --- a/perl-install/any.pm +++ b/perl-install/any.pm @@ -265,7 +265,7 @@ sub setupBootloader__general { if ($prev_clean_tmp != $clean_tmp) { if ($clean_tmp && !fsedit::has_mntpoint('/tmp', $all_hds)) { - push @{$all_hds->{special}}, { device => 'none', mntpoint => '/tmp', type => 'tmpfs' }; + push @{$all_hds->{special}}, { device => 'none', mntpoint => '/tmp', pt_type => 'tmpfs' }; } else { @{$all_hds->{special}} = grep { $_->{mntpoint} ne '/tmp' } @{$all_hds->{special}}; } diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm index db9030ad1..9d6cbd8c3 100644 --- a/perl-install/bootloader.pm +++ b/perl-install/bootloader.pm @@ -700,7 +700,7 @@ wait for default boot. } elsif (arch() !~ /ia64/) { #- search for dos (or windows) boot partition. Don't look in extended partitions! my @windows_boot_parts = - grep { isFat_or_NTFS($_) && isFat_or_NTFS({ type => fsedit::typeOfPart($_->{device}) }) } + grep { isFat_or_NTFS($_) && isFat_or_NTFS({ pt_type => fsedit::typeOfPart($_->{device}) }) } map { @{$_->{primary}{normal}} } @$hds; each_index { add_entry($bootloader, diff --git a/perl-install/diskdrake/dav.pm b/perl-install/diskdrake/dav.pm index 5d00fb4aa..23652413a 100644 --- a/perl-install/diskdrake/dav.pm +++ b/perl-install/diskdrake/dav.pm @@ -35,7 +35,7 @@ points, select \"New\".")) }, sub create { my ($in, $all_hds) = @_; - my $dav = { type => 'davfs' }; + my $dav = { pt_type => 'davfs' }; ask_server($in, $dav, $all_hds) or return; push @{$all_hds->{davs}}, $dav; config($in, $dav, $all_hds); diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm index 197bbf1d9..8ec9e80be 100644 --- a/perl-install/diskdrake/hd_gtk.pm +++ b/perl-install/diskdrake/hd_gtk.pm @@ -292,7 +292,7 @@ sub create_buttons4partitions { last; } }); - $w->set_name("PART_" . type2name($entry->{type})); + $w->set_name("PART_" . pt_type2name($entry->{pt_type})); $w->set_size_request($entry->{size} * $ratio + $minwidth, 0); gtkpack__($kind->{display_box}, $w); $w->grab_focus if $current_entry && fsedit::are_same_partitions($current_entry, $entry); @@ -325,12 +325,12 @@ sub hd2kind { sub filesystems_button_box() { my @types = (N_("Ext2"), N_("Journalised FS"), N_("Swap"), arch() =~ /sparc/ ? N_("SunOS") : arch() eq "ppc" ? N_("HFS") : N_("Windows"), N_("Other"), N_("Empty")); - my %name2type = (Ext2 => 0x83, 'Journalised FS' => 0x483, Swap => 0x82, Other => 1, "Windows" => 0xb, HFS => 0x402); + my %name2pt_type = (Ext2 => 0x83, 'Journalised FS' => 0x483, Swap => 0x82, Other => 1, "Windows" => 0xb, HFS => 0x402); gtkpack(Gtk2::HBox->new(0,0), N("Filesystem types:"), map { my $w = Gtk2::Button->new(translate($_)); - my $t = $name2type{$_}; + my $t = $name2pt_type{$_}; $w->signal_connect(clicked => sub { try_('', \&createOrChangeType, $t, current_hd(), current_part()) }); $w->can_focus(0); $w->set_name($_); @@ -339,20 +339,20 @@ sub filesystems_button_box() { } sub createOrChangeType { - my ($in, $type, $hd, $part, $all_hds) = @_; + my ($in, $pt_type, $hd, $part, $all_hds) = @_; $part ||= !fsedit::get_fstab($hd) && - { type => 0, start => 1, size => $hd->{totalsectors} - 1 }; + { pt_type => 0, start => 1, size => $hd->{totalsectors} - 1 }; $part or return; - if ($type == 1) { - $in->ask_warn('', N("Use ``%s'' instead", $part->{type} ? N("Type") : N("Create"))); - } elsif (!$type) { - $in->ask_warn('', N("Use ``%s'' instead", N("Delete"))) if $part->{type}; - } elsif ($part->{type}) { - return if $type == $part->{type}; + if ($pt_type == 1) { + $in->ask_warn('', N("Use ``%s'' instead", $part->{pt_type} ? N("Type") : N("Create"))); + } elsif (!$pt_type) { + $in->ask_warn('', N("Use ``%s'' instead", N("Delete"))) if $part->{pt_type}; + } elsif ($part->{pt_type}) { + return if $pt_type == $part->{pt_type}; $in->ask_warn('', isBusy($part) ? N("Use ``Unmount'' first") : N("Use ``%s'' instead", N("Type"))); } else { - $part->{type} = $type; + $part->{pt_type} = $pt_type; diskdrake::interactive::Create($in, $hd, $part, $all_hds); } } diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 8a029c26b..a5e4a6f7d 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -25,7 +25,7 @@ struct part { int active # one of { 0 | 0x80 } x86 only, primary only int start # in sectors int size # in sectors - int type # 0x82, 0x83, 0x6 ... + int pt_type # 0x82, 0x83, 0x6 ... string device # 'hda5', 'sdc1' ... string devfs_device # 'ide/host0/bus0/target0/lun0/part5', ... string prefer_devfs_name # should the {devfs_device} or the {device} be used in fstab @@ -144,7 +144,7 @@ struct hd_lvm inherits hd { } struct raw_hd inherits hd { - string type # 0x82, 0x83, 'nfs', ... + string pt_type # 0x82, 0x83, 'nfs', ... string mntpoint # '/', '/usr' ... string options # 'defaults', 'noauto' @@ -411,7 +411,7 @@ sub part_possible_actions { my %actions = my @l = ( N_("Mount point") => '($part->{real_mntpoint} && common::usingRamdisk()) || (!isBusy && !isSwap && !isNonMountable)', - N_("Type") => '!isBusy && $::expert && (!readonly || ($part->{type} & 0xff) == 0x83)', + N_("Type") => '!isBusy && $::expert && (!readonly || ($part->{pt_type} & 0xff) == 0x83)', N_("Options") => '$::expert', N_("Resize") => '!isBusy && !readonly && !isSpecial || isLVM($hd) && isMounted && isThisFs("xfs", $part)', N_("Move") => '!isBusy && !readonly && !isSpecial && $::expert && 0', # disable for the moment @@ -432,7 +432,7 @@ sub part_possible_actions { hasMntpoint => '$part->{mntpoint}', isPrimary => 'isPrimary($part, $hd)', ); - if ($part->{type} eq '0') { + if ($part->{pt_type} eq '0') { if_(!$hd->{readonly}, N_("Create")); } else { grep { @@ -453,14 +453,14 @@ sub Create { $part->{maxsize} = $part->{size}; $part->{size} = 0; if (!fsedit::suggest_part($part, $all_hds)) { $part->{size} = $part->{maxsize}; - $part->{type} ||= 0x483; + $part->{pt_type} ||= 0x483; } #- update adjustment for start and size, take into account the minimum partition size #- including one less sector for start due to a capacity to increase the adjustement by #- one. my ($primaryOrExtended, $migrate_files); - my $type = type2name($part->{type}); + my $type_name = pt_type2name($part->{pt_type}); my $mb_size = $part->{size} >> 11; my $has_startsector = ($::expert || arch() !~ /i.86/) && !isLVM($hd); @@ -470,9 +470,9 @@ sub Create { { label => N("Start sector: "), val => \$part->{start}, min => $def_start, max => ($max - min_partition_size($hd)), type => 'range' }, ), { label => N("Size in MB: "), val => \$mb_size, min => min_partition_size($hd) >> 11, max => $def_size >> 11, type => 'range' }, - { label => N("Filesystem type: "), val => \$type, list => [ partition_table::important_types() ], sort => 0 }, + { label => N("Filesystem type: "), val => \$type_name, list => [ partition_table::important_types() ], sort => 0 }, { label => N("Mount point: "), val => \$part->{mntpoint}, list => [ fsedit::suggestions_mntpoint($all_hds), '' ], - disabled => sub { my $p = { type => name2type($type) }; isSwap($p) || isNonMountable($p) }, type => 'combo', not_edit => 0, + disabled => sub { my $p = { pt_type => name2pt_type($type_name) }; isSwap($p) || isNonMountable($p) }, type => 'combo', not_edit => 0, }, if_($::expert && $hd->hasExtended, { label => N("Preference: "), val => \$primaryOrExtended, list => [ '', "Extended", "Primary", if_($::expert, "Extended_0x85") ] }, @@ -492,7 +492,7 @@ sub Create { } }, complete => sub { $part->{size} = from_Mb($mb_size, min_partition_size($hd), $max - $part->{start}); #- need this to be able to get back the approximation of using MB - $part->{type} = name2type($type); + $part->{pt_type} = name2pt_type($type_name); $part->{mntpoint} = '' if isNonMountable($part); $part->{mntpoint} = 'swap' if isSwap($part); fs::set_default_options($part); @@ -564,21 +564,21 @@ sub Type { my @types = partition_table::important_types(); #- when readonly, Type() is allowed only when changing between various { 0x83, 0x183, ... } - @types = grep { (name2type($_) & 0xff) == 0x83 } @types if $hd->{readonly}; + @types = grep { (name2pt_type($_) & 0xff) == 0x83 } @types if $hd->{readonly}; - my $type_name = type2name($part->{type}); + my $type_name = pt_type2name($part->{pt_type}); $in->ask_from_({ title => N("Change partition type"), messages => N("Which filesystem do you want?"), focus_first => 1, }, [ { label => N("Type"), val => \$type_name, list => \@types, sort => 0, not_edit => !$::expert } ]) or return; - my $type = $type_name && name2type($type_name); + my $pt_type = $type_name && name2pt_type($type_name); - if (isExt2($part) && isThisFs('ext3', { type => $type })) { + if (isExt2($part) && isThisFs('ext3', { pt_type => $pt_type })) { my $_w = $in->wait_message('', N("Switching from ext2 to ext3")); if (run_program::run("tune2fs", "-j", devices::make($part->{device}))) { - $part->{type} = $type; + $part->{pt_type} = $pt_type; $part->{isFormatted} = 1; #- assume that if tune2fs works, partition is formatted #- disable the fsck (don't do it together with -j in case -j fails?) @@ -589,8 +589,8 @@ sub Type { #- either we switch to non-ext3 or switching losslessly to ext3 failed !isExt2($part) or $warn->() or return; - if (defined $type) { - check_type($in, $type, $hd, $part) and fsedit::change_type($type, $hd, $part); + if (defined $pt_type) { + check_pt_type($in, $pt_type, $hd, $part) and fsedit::change_pt_type($pt_type, $hd, $part); } } @@ -870,16 +870,16 @@ sub Loopback { my $part = { maxsize => $max, size => 0, loopback_device => $real_part, notFormatted => 1 }; if (!fsedit::suggest_part($part, $all_hds)) { $part->{size} = $part->{maxsize}; - $part->{type} ||= 0x483; + $part->{pt_type} ||= 0x483; } delete $part->{mntpoint}; # we don't want the suggested mntpoint - my $type = type2name($part->{type}); + my $type_name = pt_type2name($part->{pt_type}); my $mb_size = $part->{size} >> 11; $in->ask_from(N("Loopback"), '', [ { label => N("Loopback file name: "), val => \$part->{loopback_file} }, { label => N("Size in MB: "), val => \$mb_size, min => $min >> 11, max => $max >> 11, type => 'range' }, - { label => N("Filesystem type: "), val => \$type, list => [ partition_table::important_types() ], not_edit => !$::expert, sort => 0 }, + { label => N("Filesystem type: "), val => \$type_name, list => [ partition_table::important_types() ], not_edit => !$::expert, sort => 0 }, ], complete => sub { $part->{loopback_file} or $in->ask_warn('', N("Give a file name")), return 1, 0; @@ -894,7 +894,7 @@ sub Loopback { } 0; }) or return; - $part->{type} = name2type($type); + $part->{pt_type} = name2pt_type($type_name); push @{$real_part->{loopback}}, $part; fsedit::recompute_loopbacks($all_hds); } @@ -1018,16 +1018,16 @@ sub partitions_suggestions { $fsedit::suggestions{$t}; } -sub check_type { - my ($in, $type, $hd, $part) = @_; - eval { fsedit::check_type($type, $hd, $part) }; +sub check_pt_type { + my ($in, $pt_type, $hd, $part) = @_; + eval { fsedit::check_pt_type($pt_type, $hd, $part) }; if (my $err = $@) { $in->ask_warn('', formatError($err)); return; } if ($::isStandalone) { - if (my $pkg = fsedit::package_needed_for_partition_type({ type => $type })) { - my $fs = type2fs({ type => $type }); + if (my $pkg = fsedit::package_needed_for_partition_type({ pt_type => $pt_type })) { + my $fs = type2fs({ pt_type => $pt_type }); if (!-x "/sbin/mkfs.$fs") { $in->ask_yesorno('', N("The package %s is needed. Install it?", $pkg), 1) or return; $in->do_pkgs->install($pkg); @@ -1052,7 +1052,7 @@ sub check_mntpoint { } sub check { my ($in, $hd, $part, $all_hds) = @_; - check_type($in, $part->{type}, $hd, $part) && + check_pt_type($in, $part->{pt_type}, $hd, $part) && check_mntpoint($in, $part->{mntpoint}, $hd, $part, $all_hds); } @@ -1159,15 +1159,15 @@ sub format_part_info { if (arch() eq "ppc") { my $new_value = $part->{pType}; $new_value =~ s/[^A-Za-z0-9_]//g; - $info .= N("Type: ") . $new_value . ($::expert ? sprintf " (0x%x)", $part->{type} : '') . "\n"; + $info .= N("Type: ") . $new_value . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n"; if (defined $part->{pName}) { $new_value = $part->{pName}; $new_value =~ s/[^A-Za-z0-9_]//g; $info .= N("Name: ") . $new_value . "\n"; } - } elsif ($part->{type}) { - my $type = substr(type2name($part->{type}), 0, 40); # limit the length - $info .= N("Type: ") . $type . ($::expert ? sprintf " (0x%x)", $part->{type} : '') . "\n"; + } elsif ($part->{pt_type}) { + my $type_name = substr(pt_type2name($part->{pt_type}), 0, 40); # limit the length + $info .= N("Type: ") . $type_name . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n"; } else { $info .= N("Empty") . "\n"; } @@ -1176,7 +1176,7 @@ sub format_part_info { $info .= sprintf " (%s%%)", int 100 * $part->{size} / $hd->{totalsectors} if $hd->{totalsectors}; $info .= N(", %s sectors", $part->{size}) if $::expert; $info .= "\n"; - $info .= N("Cylinder %d to %d\n", $part->{start} / $hd->cylinder_size, ($part->{start} + $part->{size} - 1) / $hd->cylinder_size) if ($::expert || !$part->{type}) && !isSpecial($part) && !isLVM($hd); + $info .= N("Cylinder %d to %d\n", $part->{start} / $hd->cylinder_size, ($part->{start} + $part->{size} - 1) / $hd->cylinder_size) if ($::expert || !$part->{pt_type}) && !isSpecial($part) && !isLVM($hd); $info .= N("Number of logical extents: %d", $part->{size} / $hd->cylinder_size) if $::expert && isLVM($hd); $info .= N("Formatted\n") if $part->{isFormatted}; $info .= N("Not formatted\n") if !$part->{isFormatted} && $part->{notFormatted}; @@ -1205,7 +1205,7 @@ sub format_part_info { sub format_part_info_short { my ($hd, $part) = @_; - $part->{type} ? + $part->{pt_type} ? partition_table::description($part) : format_part_info($hd, $part); } @@ -1231,9 +1231,9 @@ sub format_raw_hd_info { my $info = ''; $info .= N("Mount point: ") . "$raw_hd->{mntpoint}\n" if $raw_hd->{mntpoint}; $info .= format_hd_info($raw_hd); - if ($raw_hd->{type}) { - my $type = substr(type2name($raw_hd->{type}), 0, 40); # limit the length - $info .= N("Type: ") . $type . "\n"; + if ($raw_hd->{pt_type}) { + my $type_name = substr(pt_type2name($raw_hd->{pt_type}), 0, 40); # limit the length + $info .= N("Type: ") . $type_name . "\n"; } if (my $s = $raw_hd->{options}) { $s =~ s/password=([^\s,]*)/'password=' . ('x' x length($1))/e; diff --git a/perl-install/diskdrake/removable.pm b/perl-install/diskdrake/removable.pm index 6862225c5..905f6a2c4 100644 --- a/perl-install/diskdrake/removable.pm +++ b/perl-install/diskdrake/removable.pm @@ -43,11 +43,11 @@ sub mount_point { sub type { my ($in, $raw_hd) = @_; my @fs = ('auto', fs::auto_fs()); - my $type = $raw_hd->{type}; + my $pt_type = $raw_hd->{pt_type}; $in->ask_from(N("Change type"), N("Which filesystem do you want?"), - [ { label => N("Type"), val => \$type, list => [@fs], not_edit => !$::expert } ]) or return; - $raw_hd->{type} = $type; + [ { label => N("Type"), val => \$pt_type, list => [@fs], not_edit => !$::expert } ]) or return; + $raw_hd->{pt_type} = $pt_type; } 1; diff --git a/perl-install/fs.pm b/perl-install/fs.pm index 06a864f25..c5b26fbf4 100644 --- a/perl-install/fs.pm +++ b/perl-install/fs.pm @@ -41,17 +41,17 @@ sub read_fstab { $comments{$l[-1]} = $comment if $comment; map { - my ($dev, $mntpoint, $type, $options, $freq, $passno) = split; + my ($dev, $mntpoint, $fs_type, $options, $freq, $passno) = split; my $comment = $comments{$_}; $options = 'defaults' if $options eq 'rw'; # clean-up for mtab read - $type = fs2type($type); - if ($type eq 'supermount') { + my $pt_type = fs2pt_type($fs_type); + if ($pt_type eq 'supermount') { # normalize this bloody supermount $options = join(",", 'supermount', grep { if (/fs=(.*)/) { - $type = $1; + $pt_type = $1; 0; } elsif (/dev=(.*)/) { $dev = $1; @@ -62,15 +62,15 @@ sub read_fstab { 1; } } split(',', $options)); - } elsif ($type eq 'smb') { + } elsif ($pt_type eq 'smb') { # prefering type "smbfs" over "smb" - $type = 'smbfs'; + $pt_type = 'smbfs'; } $mntpoint =~ s/\\040/ /g; $dev =~ s/\\040/ /g; my $h = { - mntpoint => $mntpoint, type => $type, + mntpoint => $mntpoint, pt_type => $pt_type, options => $options, comment => $comment, if_(member('keep_freq_passno', @reading_options), freq => $freq, passno => $passno), }; @@ -110,16 +110,16 @@ sub merge_fstabs { $p->{mntpoint} = $p2->{mntpoint} if delete $p->{unsafeMntpoint}; - $p->{type} = $p2->{type} if $p2->{type} && !$loose; + $p->{pt_type} = $p2->{pt_type} if $p2->{pt_type} && !$loose; $p->{options} = $p2->{options} if $p2->{options} && !$loose; #- important to get isMounted property else DrakX may try to mount already mounted partitions :-( add2hash($p, $p2); $p->{device_alias} ||= $p2->{device_alias} || $p2->{device} if $p->{device} ne $p2->{device} && $p2->{device} !~ m|/|; - $p->{type} && $p2->{type} && $p->{type} ne $p2->{type} && type2fs($p) ne type2fs($p2) && - $p->{type} ne 'auto' && $p2->{type} ne 'auto' and + $p->{pt_type} && $p2->{pt_type} && $p->{pt_type} ne $p2->{pt_type} && type2fs($p) ne type2fs($p2) && + $p->{pt_type} ne 'auto' && $p2->{pt_type} ne 'auto' and log::l("err, fstab and partition table do not agree for $p->{device} type: " . - (type2fs($p) || type2name($p->{type})) . " vs ", (type2fs($p2) || type2name($p2->{type}))); + (type2fs($p) || pt_type2name($p->{pt_type})) . " vs ", (type2fs($p2) || pt_type2name($p2->{pt_type}))); } @l; } @@ -200,7 +200,7 @@ sub merge_info_from_mtab { my ($fstab) = @_; my @l1 = map { my $l = $_; - my %l = (type => fs2type('swap')); + my %l = (pt_type => fs2pt_type('swap')); $l{$_} = $l->{$_} foreach qw(device major minor); \%l; } read_fstab('', '/proc/swaps'); @@ -255,7 +255,7 @@ sub prepare_write_fstab { my $device = isLoopback($_) ? ($_->{mntpoint} eq '/' ? "/initrd/loopfs" : $_->{loopback_device}{mntpoint}) . $_->{loopback_file} : - part2device($o_prefix, $_->{prefer_devfs_name} ? $_->{devfs_device} : $_->{device}, $_->{type}); + part2device($o_prefix, $_->{prefer_devfs_name} ? $_->{devfs_device} : $_->{device}, $_->{pt_type}); my $real_mntpoint = $_->{mntpoint} || ${{ '/tmp/hdimage' => '/mnt/hd' }}{$_->{real_mntpoint}}; mkdir_p("$o_prefix$real_mntpoint") if $real_mntpoint =~ m|^/|; @@ -283,7 +283,7 @@ sub prepare_write_fstab { } } - my $type = type2fs($_, 'auto'); + my $fs_type = type2fs($_, 'auto'); my $dev = $_->{prefer_device_LABEL} ? 'LABEL=' . $_->{device_LABEL} : @@ -297,19 +297,19 @@ sub prepare_write_fstab { my @l = grep { $_ ne 'supermount' } split(',', $options); my @l1 = grep { member($_, 'ro', 'exec') } @l; my @l2 = difference2(\@l, \@l1); - $options = join(",", "dev=$dev", "fs=$type", @l1, if_(@l2, '--', @l2)); - ($dev, $type) = ('none', 'supermount'); + $options = join(",", "dev=$dev", "fs=$fs_type", @l1, if_(@l2, '--', @l2)); + ($dev, $fs_type) = ('none', 'supermount'); } else { #- if we were using supermount, the type could be something like ext2:vfat #- but this can't be done without supermount, so switching to "auto" - $type = 'auto' if $type =~ /:/; + $fs_type = 'auto' if $fs_type =~ /:/; } - [ $mntpoint, $_->{comment} . join(' ', $dev, $mntpoint, $type, $options || 'defaults', $freq, $passno) . "\n" ]; + [ $mntpoint, $_->{comment} . join(' ', $dev, $mntpoint, $fs_type, $options || 'defaults', $freq, $passno) . "\n" ]; } else { () } - } grep { $_->{device} && ($_->{mntpoint} || $_->{real_mntpoint}) && $_->{type} && ($_->{isFormatted} || !$_->{notFormatted}) } @$fstab; + } grep { $_->{device} && ($_->{mntpoint} || $_->{real_mntpoint}) && $_->{pt_type} && ($_->{isFormatted} || !$_->{notFormatted}) } @$fstab; join('', map { $_->[1] } sort { $a->[0] cmp $b->[0] } @l), \@smb_credentials; } @@ -331,8 +331,8 @@ sub write_fstab { } sub part2device { - my ($prefix, $dev, $type) = @_; - $dev eq 'none' || member($type, qw(nfs smbfs davfs)) ? + my ($prefix, $dev, $pt_type) = @_; + $dev eq 'none' || member($pt_type, qw(nfs smbfs davfs)) ? $dev : do { my $dir = $dev =~ m!^(/|LABEL=)! ? '' : '/dev/'; @@ -373,13 +373,13 @@ sub mount_options_unpack { push @{$per_fs{$_}}, 'usrquota', 'grpquota' foreach 'ext2', 'ext3', 'xfs'; while (my ($fs, $l) = each %per_fs) { - isThisFs($fs, $part) || $part->{type} eq 'auto' && member($fs, @auto_fs) or next; + isThisFs($fs, $part) || $part->{pt_type} eq 'auto' && member($fs, @auto_fs) or next; $non_defaults->{$_} = 1 foreach @$l; } $non_defaults->{encrypted} = 1 if !$part->{isFormatted} || isSwap($part); - $non_defaults->{supermount} = 1 if $part->{type} =~ /:/ || member(type2fs($part), 'auto', @auto_fs); + $non_defaults->{supermount} = 1 if $part->{pt_type} =~ /:/ || member(type2fs($part), 'auto', @auto_fs); my $defaults = { reverse %$non_defaults }; my %options = map { $_ => '' } keys %$non_defaults; @@ -504,7 +504,7 @@ sub set_default_options { if ($part->{is_removable}) { $options->{supermount} = $opts{useSupermount} && !($opts{useSupermount} eq 'magicdev' && $part->{media_type} eq 'cdrom'); - $part->{type} = !$options->{supermount} ? 'auto' : + $part->{pt_type} = !$options->{supermount} ? 'auto' : $part->{media_type} eq 'cdrom' ? 'udf:iso9660' : 'ext2:vfat'; } @@ -532,7 +532,7 @@ sub set_default_options { if (isThisFs('smbfs', $part)) { add2hash($options, { 'username=' => '%' }) if !$options->{'credentials='}; } - if (isFat($part) || member('vfat', split(':', $part->{type})) || isThisFs('auto', $part)) { + if (isFat($part) || member('vfat', split(':', $part->{pt_type})) || isThisFs('auto', $part)) { put_in_hash($options, { user => 1, noexec => 0, @@ -548,7 +548,7 @@ sub set_default_options { 'umask=0' => $opts{security} < 3, 'umask=0022' => $opts{security} < 4, }); } - if (member('iso9660', split(':', $part->{type})) || isThisFs('auto', $part)) { + if (member('iso9660', split(':', $part->{pt_type})) || isThisFs('auto', $part)) { put_in_hash($options, { user => 1, noexec => 0, 'iocharset=' => $opts{iocharset} }); } if (isThisFs('reiserfs', $part)) { @@ -613,8 +613,8 @@ sub get_raw_hds { $all_hds->{davs} = [ grep { isThisFs('davfs', $_) } @fstab ]; $all_hds->{special} = [ (grep { isThisFs('tmpfs', $_) } @fstab), - { device => 'none', mntpoint => '/proc', type => 'proc' }, - { device => 'none', mntpoint => '/dev/pts', type => 'devpts', options => 'mode=0620' }, + { device => 'none', mntpoint => '/proc', pt_type => 'proc' }, + { device => 'none', mntpoint => '/dev/pts', pt_type => 'devpts', options => 'mode=0620' }, ]; } @@ -672,7 +672,7 @@ sub real_format_part { my $dev = $part->{real_device} || $part->{device}; my @options = if_($part->{toFormatCheck}, "-c"); - log::l("formatting device $dev (type ", type2name($part->{type}), ")"); + log::l("formatting device $dev (type ", pt_type2name($part->{pt_type}), ")"); if (isExt2($part)) { push @options, "-F" if isLoopback($part); @@ -699,7 +699,7 @@ sub real_format_part { my $check_blocks = any { /^-c$/ } @options; swap::make($dev, $check_blocks); } else { - die N("I don't know how to format %s in type %s", $part->{device}, type2name($part->{type})); + die N("I don't know how to format %s in type %s", $part->{device}, pt_type2name($part->{pt_type})); } $part->{isFormatted} = 1; } diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm index 89e999b01..ce09f1873 100644 --- a/perl-install/fsedit.pm +++ b/perl-install/fsedit.pm @@ -19,26 +19,26 @@ use fs; %suggestions = ( N_("simple") => [ - { mntpoint => "/", size => 300 << 11, type =>0x483, ratio => 5, maxsize => 6000 << 11 }, - { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 1, maxsize => 500 << 11 }, - { mntpoint => "/home", size => 300 << 11, type =>0x483, ratio => 3 }, + { mntpoint => "/", size => 300 << 11, pt_type =>0x483, ratio => 5, maxsize => 6000 << 11 }, + { mntpoint => "swap", size => 64 << 11, pt_type => 0x82, ratio => 1, maxsize => 500 << 11 }, + { mntpoint => "/home", size => 300 << 11, pt_type =>0x483, ratio => 3 }, ], N_("with /usr") => [ - { mntpoint => "/", size => 250 << 11, type =>0x483, ratio => 1, maxsize => 2000 << 11 }, - { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 1, maxsize => 500 << 11 }, - { mntpoint => "/usr", size => 300 << 11, type =>0x483, ratio => 4, maxsize => 4000 << 11 }, - { mntpoint => "/home", size => 100 << 11, type =>0x483, ratio => 3 }, + { mntpoint => "/", size => 250 << 11, pt_type =>0x483, ratio => 1, maxsize => 2000 << 11 }, + { mntpoint => "swap", size => 64 << 11, pt_type => 0x82, ratio => 1, maxsize => 500 << 11 }, + { mntpoint => "/usr", size => 300 << 11, pt_type =>0x483, ratio => 4, maxsize => 4000 << 11 }, + { mntpoint => "/home", size => 100 << 11, pt_type =>0x483, ratio => 3 }, ], N_("server") => [ - { mntpoint => "/", size => 150 << 11, type =>0x483, ratio => 1, maxsize => 800 << 11 }, - { mntpoint => "swap", size => 64 << 11, type => 0x82, ratio => 2, maxsize => 800 << 11 }, - { mntpoint => "/usr", size => 300 << 11, type =>0x483, ratio => 4, maxsize => 4000 << 11 }, - { mntpoint => "/var", size => 200 << 11, type =>0x483, ratio => 3 }, - { mntpoint => "/home", size => 150 << 11, type =>0x483, ratio => 3 }, - { mntpoint => "/tmp", size => 150 << 11, type =>0x483, ratio => 2, maxsize => 1000 << 11 }, + { mntpoint => "/", size => 150 << 11, pt_type =>0x483, ratio => 1, maxsize => 800 << 11 }, + { mntpoint => "swap", size => 64 << 11, pt_type => 0x82, ratio => 2, maxsize => 800 << 11 }, + { mntpoint => "/usr", size => 300 << 11, pt_type =>0x483, ratio => 4, maxsize => 4000 << 11 }, + { mntpoint => "/var", size => 200 << 11, pt_type =>0x483, ratio => 3 }, + { mntpoint => "/home", size => 150 << 11, pt_type =>0x483, ratio => 3 }, + { mntpoint => "/tmp", size => 150 << 11, pt_type =>0x483, ratio => 2, maxsize => 1000 << 11 }, ], ); foreach (values %suggestions) { if (arch() =~ /ia64/) { - @$_ = ({ mntpoint => "/boot/efi", size => 50 << 11, type => 0xef, ratio => 1, maxsize => 150 << 11 }, @$_); + @$_ = ({ mntpoint => "/boot/efi", size => 50 << 11, pt_type => 0xef, ratio => 1, maxsize => 150 << 11 }, @$_); } } @@ -113,10 +113,10 @@ sub raids { my @raw_mdparts = map { /([^\[]+)/ } split ' ', $mdparts; - my $type = typeOfPart("md$nb"); - log::l("RAID: found md$nb (raid $level) chunks $chunks ", if_($type, "type $type "), "with parts ", join(", ", @raw_mdparts)); - $raids[$nb] = { 'chunk-size' => $chunks, type => $type || 0x83, raw_mdparts => \@raw_mdparts, - device => "md$nb", notFormatted => !$type, level => $level }; + my $pt_type = typeOfPart("md$nb"); + log::l("RAID: found md$nb (raid $level) chunks $chunks ", if_($pt_type, "type $pt_type "), "with parts ", join(", ", @raw_mdparts)); + $raids[$nb] = { 'chunk-size' => $chunks, pt_type => $pt_type || 0x83, raw_mdparts => \@raw_mdparts, + device => "md$nb", notFormatted => !$pt_type, level => $level }; } my %devname2part = map { $_->{dev} => { %$_, device => $_->{dev} } } devices::read_proc_partitions_raw(); @@ -127,7 +127,7 @@ sub raids { my $mdpart = $devname2part{$_} || { device => $_ }; if (my $part = find { is_same_hd($mdpart, $_) } @parts, @raids) { $part->{raid} = $::i; - $part->{type} = 0xfd; + $part->{pt_type} = 0xfd; delete $part->{mntpoint}; $part; } else { @@ -205,7 +205,7 @@ sub hds { if ($hd->{readonly}) { log::l("using /proc/partitions since diskdrake failed :("); use_proc_partitions($hd); - } elsif (exists $hd->{usb_description} && ($hd->{type} ||= typeOfPart($hd->{device}))) { + } elsif (exists $hd->{usb_description} && ($hd->{pt_type} ||= typeOfPart($hd->{device}))) { push @raw_hds, $hd; next; } elsif ($o_ask_before_blanking && $o_ask_before_blanking->($hd->{device}, $err)) { @@ -221,13 +221,13 @@ sub hds { } # special case for Various type - $_->{type} = typeOfPart($_->{device}) || 0x100 foreach grep { $_->{type} == 0x100 } partition_table::get_normal_parts($hd); + $_->{pt_type} = typeOfPart($_->{device}) || 0x100 foreach grep { $_->{pt_type} == 0x100 } partition_table::get_normal_parts($hd); #- special case for type overloading (eg: reiserfs is 0x183) - foreach (grep { isExt2($_) || $_->{type} == 0x7 || $_->{type} == 0x17 } partition_table::get_normal_parts($hd)) { - my $wanted_type = $_->{type} == 0x17 ? 0x7 : $_->{type}; - my $type = typeOfPart($_->{device}); - $_->{type} = $type if ($type & 0xff) == $wanted_type || $type && $hd->isa('partition_table::gpt'); + foreach (grep { isExt2($_) || $_->{pt_type} == 0x7 || $_->{pt_type} == 0x17 } partition_table::get_normal_parts($hd)) { + my $wanted_pt_type = $_->{pt_type} == 0x17 ? 0x7 : $_->{pt_type}; + my $pt_type = typeOfPart($_->{device}); + $_->{pt_type} = $pt_type if ($pt_type & 0xff) == $wanted_pt_type || $pt_type && $hd->isa('partition_table::gpt'); } foreach (partition_table::get_normal_parts($hd)) { @@ -303,7 +303,7 @@ sub read_proc_partitions { $part->{device} = $dev; $part->{size} *= 2; # from KB to sectors - $part->{type} = typeOfPart($dev); + $part->{pt_type} = typeOfPart($dev); $part->{start} = $prev_part ? $prev_part->{start} + $prev_part->{size} : 0; $prev_part = $part; delete $part->{dev}; # cleanup @@ -338,7 +338,7 @@ sub is_same_hd { #- are_same_partitions() do not look at the device name since things may have changed sub are_same_partitions { my ($part1, $part2) = @_; - foreach ('start', 'size', 'type', 'rootDevice') { + foreach ('start', 'size', 'pt_type', 'rootDevice') { $part1->{$_} eq $part2->{$_} or return; } 1; @@ -360,7 +360,7 @@ sub get_fstab_and_holes { if (isLVM($_)) { my @parts = partition_table::get_normal_parts($_); my $free = $_->{totalsectors} - sum map { $_->{size} } @parts; - my $free_part = { start => 0, size => $free, type => 0, rootDevice => $_->{VG_name} }; + my $free_part = { start => 0, size => $free, pt_type => 0, rootDevice => $_->{VG_name} }; @parts, if_($free >= $_->cylinder_size, $free_part); } else { partition_table::get_normal_parts_and_holes($_); @@ -368,7 +368,7 @@ sub get_fstab_and_holes { } @_; } sub get_holes { - grep { $_->{type} == 0 } get_fstab_and_holes(@_); + grep { $_->{pt_type} == 0 } get_fstab_and_holes(@_); } sub get_all_fstab { @@ -390,7 +390,7 @@ sub get_all_fstab_and_holes { } sub get_all_holes { my ($all_hds) = @_; - grep { $_->{type} == 0 } get_all_fstab_and_holes($all_hds); + grep { $_->{pt_type} == 0 } get_all_fstab_and_holes($all_hds); } sub all_free_space { @@ -485,13 +485,13 @@ sub suggest_part { my ($best) = grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} } grep { $_->{size} <= ($part->{maxsize} || $part->{size}) } - grep { !$part->{type} || $part->{type} == $_->{type} || isTrueFS($part) && isTrueFS($_) } + grep { !$part->{pt_type} || $part->{pt_type} == $_->{pt_type} || isTrueFS($part) && isTrueFS($_) } @local_suggestions; defined $best or return; #- sorry no suggestion :( $part->{mntpoint} = $best->{mntpoint}; - $part->{type} = $best->{type} if !(isTrueFS($best) && isTrueFS($part)); + $part->{pt_type} = $best->{pt_type} if !(isTrueFS($best) && isTrueFS($part)); $part->{size} = computeSize($part, $best, $all_hds, \@local_suggestions); foreach ('options', 'lv_name', 'encrypt_key') { $part->{$_} = $best->{$_} if $best->{$_}; @@ -519,11 +519,11 @@ sub get_root_ { } sub get_root { &get_root_ || {} } -#- do this before modifying $part->{type} -sub check_type { - my ($type, $_hd, $part) = @_; - isThisFs("jfs", { type => $type }) && $part->{size} < 16 << 11 and die N("You can't use JFS for partitions smaller than 16MB"); - isThisFs("reiserfs", { type => $type }) && $part->{size} < 32 << 11 and die N("You can't use ReiserFS for partitions smaller than 32MB"); +#- do this before modifying $part->{pt_type} +sub check_pt_type { + my ($pt_type, $_hd, $part) = @_; + isThisFs("jfs", { pt_type => $pt_type }) && $part->{size} < 16 << 11 and die N("You can't use JFS for partitions smaller than 16MB"); + isThisFs("reiserfs", { pt_type => $pt_type }) && $part->{size} < 32 << 11 and die N("You can't use ReiserFS for partitions smaller than 32MB"); } sub package_needed_for_partition_type { @@ -648,7 +648,7 @@ sub auto_allocate_raids { my %h = %$md; delete @h{'hd', 'parts'}; - put_in_hash($part, \%h); # mntpoint, level, chunk-size, type + put_in_hash($part, \%h); # mntpoint, level, chunk-size, pt_type raid::updateSize($part); } } @@ -762,14 +762,14 @@ sub move { } } -sub change_type { - my ($type, $hd, $part) = @_; - $type != $part->{type} or return; - check_type($type, $hd, $part); +sub change_pt_type { + my ($pt_type, $hd, $part) = @_; + $pt_type != $part->{pt_type} or return; + check_pt_type($pt_type, $hd, $part); $hd->{isDirty} = 1; $part->{mntpoint} = '' if isSwap($part) && $part->{mntpoint} eq "swap"; - $part->{mntpoint} = '' if isRawLVM({ type => $type }) || isRawRAID({ type => $type }); - $part->{type} = $type; + $part->{mntpoint} = '' if isRawLVM({ pt_type => $pt_type }) || isRawRAID({ pt_type => $pt_type }); + $part->{pt_type} = $pt_type; $part->{notFormatted} = 1; $part->{isFormatted} = 0; fs::rationalize_options($part); @@ -784,7 +784,7 @@ sub rescuept($) { local $_; while (<$F>) { my ($st, $si, $id) = /start=\s*(\d+),\s*size=\s*(\d+),\s*Id=\s*(\d+)/ or next; - my $part = { start => $st, size => $si, type => hex($id) }; + my $part = { start => $st, size => $si, pt_type => hex($id) }; if (isExtended($part)) { $ext = $part; } else { diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm index 8ab92f8fd..f1c052877 100644 --- a/perl-install/install_any.pm +++ b/perl-install/install_any.pm @@ -793,7 +793,7 @@ sub g_auto_install { require pkgs; $o->{default_packages} = pkgs::selected_leaves($::o->{packages}); - my @fields = qw(mntpoint type size); + my @fields = qw(mntpoint pt_type size); $o->{partitions} = [ map { my %l; @l{@fields} = @$_{@fields}; \%l } grep { $_->{mntpoint} } @{$::o->{fstab}} ]; exists $::o->{$_} and $o->{$_} = $::o->{$_} foreach qw(locale authentication mouse netc timezone superuser intf keyboard users partitioning isUpgrade manualFstab nomouseprobe crypto security security_user libsafe netcnx useSupermount autoExitInstall X services); #- TODO modules bootloader @@ -977,6 +977,12 @@ sub loadO { $O and add2hash_($o ||= {}, $O); } $O and bless $o, ref $O; + + #- handle backward compatibility for things that changed + foreach (@{$o->{partitions} || []}, @{$o->{manualFstab} || []}) { + $_->{pt_type} ||= $_->{type}; + } + $o; } @@ -1104,7 +1110,7 @@ sub getHds { $o->{fstab} = [ fsedit::get_really_all_fstab($all_hds) ]; fs::merge_info_from_mtab($o->{fstab}); - my @win = grep { isFat_or_NTFS($_) && isFat_or_NTFS({ type => fsedit::typeOfPart($_->{device}) }) } @{$o->{fstab}}; + my @win = grep { isFat_or_NTFS($_) && isFat_or_NTFS({ pt_type => fsedit::typeOfPart($_->{device}) }) } @{$o->{fstab}}; log::l("win parts: ", join ",", map { $_->{device} } @win) if @win; if (@win == 1) { #- Suggest /boot/efi on ia64. @@ -1116,7 +1122,7 @@ sub getHds { } } - my @sunos = grep { isSunOS($_) && type2name($_->{type}) =~ /root/i } @{$o->{fstab}}; #- take only into account root partitions. + my @sunos = grep { isSunOS($_) && pt_type2name($_->{pt_type}) =~ /root/i } @{$o->{fstab}}; #- take only into account root partitions. if (@sunos) { my $v = ''; map { $_->{mntpoint} = $_->{unsafeMntpoint} = "/mnt/sunos" . ($v && ++$v) } @sunos; diff --git a/perl-install/install_interactive.pm b/perl-install/install_interactive.pm index 186397e37..e86c10bb6 100644 --- a/perl-install/install_interactive.pm +++ b/perl-install/install_interactive.pm @@ -121,8 +121,8 @@ sub partitionWizardSolutions { { label => N("Swap partition size in MB: "), val => \$s_swap, min => $min_swap >> 11, max => $max_swap >> 11, type => 'range' }, ]) or return; push @{$part->{loopback}}, - { type =>0x483, loopback_file => '/lnx4win/linuxsys.img', mntpoint => '/', size => $s_root << 11, loopback_device => $part, notFormatted => 1 }, - { type => 0x82, loopback_file => '/lnx4win/swapfile', mntpoint => 'swap', size => $s_swap << 11, loopback_device => $part, notFormatted => 1 }; + { pt_type =>0x483, loopback_file => '/lnx4win/linuxsys.img', mntpoint => '/', size => $s_root << 11, loopback_device => $part, notFormatted => 1 }, + { pt_type => 0x82, loopback_file => '/lnx4win/swapfile', mntpoint => 'swap', size => $s_swap << 11, loopback_device => $part, notFormatted => 1 }; fsedit::recompute_loopbacks($all_hds); 1; } ]; diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm index eda66496e..ec83e3fd9 100644 --- a/perl-install/install_steps.pm +++ b/perl-install/install_steps.pm @@ -215,7 +215,7 @@ sub doPartitionDisksAfter { cat_("/proc/mounts") =~ m|(\S+)\s+/tmp/nfsimage| && !any { $_->{mntpoint} eq "/mnt/nfs" } @{$o->{all_hds}{nfss}} and - push @{$o->{all_hds}{nfss}}, { type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" }; + push @{$o->{all_hds}{nfss}}, { pt_type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" }; } #------------------------------------------------------------------------------ @@ -243,7 +243,7 @@ sub ask_mntpoint_s {#-}}} $m{$m} = 1; #- in case the type does not correspond, force it to ext3 - $_->{type} = 0x483 if $m =~ m|^/| && !isTrueFS($_) && !isOtherAvailableFS($_); + $_->{pt_type} = 0x483 if $m =~ m|^/| && !isTrueFS($_) && !isOtherAvailableFS($_); } 1; } @@ -269,7 +269,7 @@ sub choosePartitionsToFormat($$) { my $t = fsedit::typeOfPart($_->{device}); $_->{toFormatUnsure} ||= #- if detected dos/win, it's not precise enough to just compare the types (too many of them) - (!$t || isOtherAvailableFS({ type => $t }) ? !isOtherAvailableFS($_) : $t != $_->{type}); + (!$t || isOtherAvailableFS({ pt_type => $t }) ? !isOtherAvailableFS($_) : $t != $_->{pt_type}); } } } diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm index d7a3369bd..92f4fa805 100644 --- a/perl-install/install_steps_interactive.pm +++ b/perl-install/install_steps_interactive.pm @@ -286,7 +286,7 @@ sub doPartitionDisks { log::l("creating bootstrap partition on drive /dev/$freepart->{hd}{device}, block $freepart->{start}"); $partition_table::mac::bootstrap_part = $freepart->{part}; log::l("bootstrap now at $partition_table::mac::bootstrap_part"); - fsedit::add($freepart->{hd}, { start => $freepart->{start}, size => 1 << 11, type => 0x401, mntpoint => '' }, $o->{all_hds}, { force => 1, primaryOrExtended => 'Primary' }); + fsedit::add($freepart->{hd}, { start => $freepart->{start}, size => 1 << 11, pt_type => 0x401, mntpoint => '' }, $o->{all_hds}, { force => 1, primaryOrExtended => 'Primary' }); $new_bootstrap = 1; } else { $o->ask_warn('', N("No free space for 1MB bootstrap! Install will continue, but to boot your system, you'll need to create the bootstrap partition in DiskDrake")); diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm index 0770bf2b9..c660e4d95 100644 --- a/perl-install/lvm.pm +++ b/perl-install/lvm.pm @@ -92,10 +92,10 @@ sub get_lvs { [ map { my $device = "$lvm->{VG_name}/$_"; - my $type = -e "/dev/$device" && fsedit::typeOfPart($device); + my $pt_type = -e "/dev/$device" && fsedit::typeOfPart($device); { device => $device, - type => $type || 0x83, + type => $pt_type || 0x83, size => get_lv_size($device) } } @l ]; diff --git a/perl-install/network/smbnfs.pm b/perl-install/network/smbnfs.pm index 97f2bd6e6..d9b53aedb 100644 --- a/perl-install/network/smbnfs.pm +++ b/perl-install/network/smbnfs.pm @@ -35,8 +35,8 @@ sub to_fullstring { $class->to_dev($e) . ($comment ? " ($comment)" : ''); } sub to_fstab_entry_raw { - my ($class, $e, $type) = @_; - my $fs_entry = { device => $class->to_dev($e), type => $type }; + my ($class, $e, $pt_type) = @_; + my $fs_entry = { device => $class->to_dev($e), pt_type => $pt_type }; fs::set_default_options($fs_entry); $fs_entry; } diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm index b8f96fb1a..c7f968c6f 100644 --- a/perl-install/partition_table.pm +++ b/perl-install/partition_table.pm @@ -6,7 +6,7 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @important_types @important_types2 @fie @ISA = qw(Exporter); %EXPORT_TAGS = ( - types => [ qw(type2name type2fs name2type fs2type isExtended isExt2 isThisFs isTrueLocalFS isTrueFS isSwap isDos isWin isFat isFat_or_NTFS isSunOS isOtherAvailableFS isPrimary isRawLVM isRawRAID isRAID isLVM isMountableRW isNonMountable isPartOfLVM isPartOfRAID isPartOfLoopback isLoopback isMounted isBusy isSpecial maybeFormatted isApple isAppleBootstrap isEfi) ], + types => [ qw(pt_type2name type2fs name2pt_type fs2pt_type isExtended isExt2 isThisFs isTrueLocalFS isTrueFS isSwap isDos isWin isFat isFat_or_NTFS isSunOS isOtherAvailableFS isPrimary isRawLVM isRawRAID isRAID isLVM isMountableRW isNonMountable isPartOfLVM isPartOfRAID isPartOfLoopback isLoopback isMounted isBusy isSpecial maybeFormatted isApple isAppleBootstrap isEfi) ], ); @EXPORT_OK = map { @$_ } values %EXPORT_TAGS; @@ -27,7 +27,7 @@ use log; @bad_types = ('Empty', 'DOS 3.3+ Extended Partition', 'Win95: Extended partition, LBA-mapped', 'Linux extended partition'); -my %types = ( +my %pt_types = ( 0x0 => 'Empty', if_(arch() =~ /^ppc/, 0x183 => 'Journalised FS: ReiserFS', @@ -177,7 +177,7 @@ if_(arch() =~ /^ppc/, 0xff => 'Xenix Bad Block Table', ); -my %type2fs = ( +my %pt_type2fs = ( arch() =~ /^ppc/ ? ( 0x07 => 'hpfs', ) : ( @@ -215,41 +215,42 @@ arch() !~ /sparc/ ? ( 0x402 => 'hfs', ); -my %types_rev = reverse %types; -my %fs2type = reverse %type2fs; +my %pt_types_rev = reverse %pt_types; +my %fs2pt_type = reverse %pt_type2fs; 1; sub important_types() { - my @l = (@important_types, if_($::expert, @important_types2, sort values %types)); + my @l = (@important_types, if_($::expert, @important_types2, sort values %pt_types)); difference2(\@l, \@bad_types); } sub type2fs { my ($part, $o_default) = @_; - my $type = $part->{type}; - $type2fs{$type} || $type =~ /^(\d+)$/ && $o_default || $type; + my $pt_type = $part->{pt_type}; + $pt_type2fs{$pt_type} || $pt_type =~ /^(\d+)$/ && $o_default || $pt_type; } -sub fs2type { $fs2type{$_[0]} || $_[0] } -sub type2name { $types{$_[0]} || $_[0] } -sub name2type { +sub fs2pt_type { $fs2pt_type{$_[0]} || $_[0] } +sub pt_type2name { $pt_types{$_[0]} || $_[0] } +sub name2pt_type { local ($_) = @_; - /0x(.*)/ ? hex $1 : $types_rev{$_} || $_; + /0x(.*)/ ? hex $1 : $pt_types_rev{$_} || $_; } +#sub name2type { { pt_type => name2pt_type($_[0]) } } -sub isEfi { arch() =~ /ia64/ && $_[0]{type} == 0xef } -sub isWholedisk { arch() =~ /^sparc/ && $_[0]{type} == 5 } -sub isExtended { arch() !~ /^sparc/ && ($_[0]{type} == 5 || $_[0]{type} == 0xf || $_[0]{type} == 0x85) } -sub isRawLVM { $_[0]{type} == 0x8e } -sub isRawRAID { $_[0]{type} == 0xfd } +sub isEfi { arch() =~ /ia64/ && $_[0]{pt_type} == 0xef } +sub isWholedisk { arch() =~ /^sparc/ && $_[0]{pt_type} == 5 } +sub isExtended { arch() !~ /^sparc/ && ($_[0]{pt_type} == 5 || $_[0]{pt_type} == 0xf || $_[0]{pt_type} == 0x85) } +sub isRawLVM { $_[0]{pt_type} == 0x8e } +sub isRawRAID { $_[0]{pt_type} == 0xfd } sub isSwap { type2fs($_[0]) eq 'swap' } sub isExt2 { type2fs($_[0]) eq 'ext2' } -sub isDos { arch() !~ /^sparc/ && ${{ 1 => 1, 4 => 1, 6 => 1 }}{$_[0]{type}} } -sub isWin { ${{ 0xb => 1, 0xc => 1, 0xe => 1, 0x1b => 1, 0x1c => 1, 0x1e => 1 }}{$_[0]{type}} } +sub isDos { arch() !~ /^sparc/ && ${{ 1 => 1, 4 => 1, 6 => 1 }}{$_[0]{pt_type}} } +sub isWin { ${{ 0xb => 1, 0xc => 1, 0xe => 1, 0x1b => 1, 0x1c => 1, 0x1e => 1 }}{$_[0]{pt_type}} } sub isFat { isDos($_[0]) || isWin($_[0]) } -sub isFat_or_NTFS { isDos($_[0]) || isWin($_[0]) || $_[0]{type} == 0x107 } -sub isSunOS { arch() =~ /sparc/ && ${{ 0x1 => 1, 0x2 => 1, 0x4 => 1, 0x6 => 1, 0x7 => 1, 0x8 => 1 }}{$_[0]{type}} } +sub isFat_or_NTFS { isDos($_[0]) || isWin($_[0]) || $_[0]{pt_type} == 0x107 } +sub isSunOS { arch() =~ /sparc/ && ${{ 0x1 => 1, 0x2 => 1, 0x4 => 1, 0x6 => 1, 0x7 => 1, 0x8 => 1 }}{$_[0]{pt_type}} } sub isApple { type2fs($_[0]) eq 'apple' && defined $_[0]{isDriver} } sub isAppleBootstrap { type2fs($_[0]) eq 'apple' && defined $_[0]{isBoot} } sub isHiddenMacPart { defined $_[0]{isMap} } @@ -289,7 +290,7 @@ sub description { formatXiB($hd->{totalsectors} || $hd->{size}, 512), $hd->{info} && ", $hd->{info}", $hd->{mntpoint} && ", " . $hd->{mntpoint}, - $hd->{type} && ", " . type2name($hd->{type}); + $hd->{pt_type} && ", " . pt_type2name($hd->{pt_type}); } sub isPrimary { @@ -399,11 +400,11 @@ sub assign_device_numbers { #- isFat_or_NTFS isn't true for 0x7 partitions, only for 0x107. #- alas 0x107 is not set correctly at this stage #- solution: don't bother with 0x7 vs 0x107 here - my ($c, @others) = grep { isFat_or_NTFS($_) || $_->{type} == 0x7 || $_->{type} == 0x17 } @{$hd->{primary}{normal}}; + my ($c, @others) = grep { isFat_or_NTFS($_) || $_->{pt_type} == 0x7 || $_->{pt_type} == 0x17 } @{$hd->{primary}{normal}}; $i = ord 'C'; $c->{device_windobe} = chr($i++) if $c; - $_->{device_windobe} = chr($i++) foreach grep { isFat_or_NTFS($_) || $_->{type} == 0x7 || $_->{type} == 0x17 } map { $_->{normal} } @{$hd->{extended}}; + $_->{device_windobe} = chr($i++) foreach grep { isFat_or_NTFS($_) || $_->{pt_type} == 0x7 || $_->{pt_type} == 0x17 } map { $_->{normal} } @{$hd->{extended}}; $_->{device_windobe} = chr($i++) foreach @others; } @@ -435,7 +436,7 @@ sub adjust_main_extended { $start = min($start, $_->{start}); $end = max($end, $_->{start} + $_->{size}); $only_linux &&= isTrueLocalFS($_) || isSwap($_); - $has_win_lba ||= $_->{type} == 0xc || $_->{type} == 0xe; + $has_win_lba ||= $_->{pt_type} == 0xc || $_->{pt_type} == 0xe; } $l->{start} = $hd->{primary}{extended}{start} = $start; $l->{size} = $hd->{primary}{extended}{size} = $end - $start; @@ -474,12 +475,12 @@ sub get_normal_parts_and_holes { my @l = map { my $current = $start; $start = $_->{start} + $_->{size}; - my $hole = { start => $current, size => $_->{start} - $current, type => 0, rootDevice => $hd->{device} }; + my $hole = { start => $current, size => $_->{start} - $current, pt_type => 0, rootDevice => $hd->{device} }; $hole, $_; } sort { $a->{start} <=> $b->{start} } grep { !isWholedisk($_) } get_normal_parts($hd); - push @l, { start => $start, size => $last - $start, type => 0, rootDevice => $hd->{device} }; - grep { $_->{type} || $_->{size} >= $hd->cylinder_size } @l; + push @l, { start => $start, size => $last - $start, pt_type => 0, rootDevice => $hd->{device} }; + grep { $_->{pt_type} || $_->{size} >= $hd->cylinder_size } @l; } sub read_one($$) { @@ -516,8 +517,8 @@ sub read_one($$) { } my @extended = $hd->hasExtended ? grep { isExtended($_) } @$pt : (); - my @normal = grep { $_->{size} && $_->{type} && !isExtended($_) } @$pt; - my $nb_special_empty = int(grep { $_->{size} && $_->{type} == 0 } @$pt); + my @normal = grep { $_->{size} && $_->{pt_type} && !isExtended($_) } @$pt; + my $nb_special_empty = int(grep { $_->{size} && $_->{pt_type} == 0 } @$pt); @extended > 1 and die "more than one extended partition"; @@ -733,7 +734,7 @@ sub remove { 0; } -# create of partition at starting at `start', of size `size' and of type `type' (nice comment, uh?) +# create of partition at starting at `start', of size `size' and of type `pt_type' (nice comment, uh?) sub add_primary { my ($hd, $part) = @_; @@ -777,13 +778,13 @@ The only solution is to move your primary partitions to have the hole next to th $l->{start} = round_down($l->{normal}{start} - 1, $hd->cylinder_size); $l->{size} = $l->{normal}{start} + $l->{normal}{size} - $l->{start}; my $ext = { %$l }; - unshift @{$hd->{extended}}, { type => 5, raw => [ $part, $ext, {}, {} ], normal => $part, extended => $ext }; + unshift @{$hd->{extended}}, { pt_type => 5, raw => [ $part, $ext, {}, {} ], normal => $part, extended => $ext }; #- size will be autocalculated :) } else { my ($ext, $ext_size) = is_empty_array_ref($hd->{extended}) ? ($hd->{primary}, -1) : #- -1 size will be computed by adjust_main_extended (top(@{$hd->{extended}}), $part->{size}); - my %ext = (type => $extended_type || 5, start => $part->{start}, size => $ext_size); + my %ext = (pt_type => $extended_type || 5, start => $part->{start}, size => $ext_size); $hd->raw_add($ext->{raw}, \%ext); $ext->{extended} = \%ext; 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, diff --git a/perl-install/raid.pm b/perl-install/raid.pm index 7237af929..8579c26ac 100644 --- a/perl-install/raid.pm +++ b/perl-install/raid.pm @@ -23,7 +23,7 @@ sub nb { sub new { my ($raids, @parts) = @_; my $nb = @$raids; - $raids->[$nb] = { 'chunk-size' => "64k", type => 0x483, disks => [ @parts ], device => "md$nb", notFormatted => 1, level => 1 }; + $raids->[$nb] = { 'chunk-size' => "64k", pt_type => 0x483, disks => [ @parts ], device => "md$nb", notFormatted => 1, level => 1 }; foreach my $part (@parts) { $part->{raid} = $nb; delete $part->{mntpoint}; -- cgit v1.2.1