summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/any.pm7
-rw-r--r--perl-install/bootloader.pm16
-rw-r--r--perl-install/diskdrake/dav.pm2
-rw-r--r--perl-install/diskdrake/hd_gtk.pm20
-rw-r--r--perl-install/diskdrake/interactive.pm107
-rw-r--r--perl-install/diskdrake/removable.pm6
-rw-r--r--perl-install/fs.pm95
-rw-r--r--perl-install/fs/format.pm13
-rw-r--r--perl-install/fs/type.pm334
-rw-r--r--perl-install/fsedit.pm133
-rw-r--r--perl-install/install2.pm2
-rw-r--r--perl-install/install_any.pm14
-rw-r--r--perl-install/install_interactive.pm15
-rw-r--r--perl-install/install_steps.pm13
-rw-r--r--perl-install/install_steps_interactive.pm14
-rw-r--r--perl-install/loopback.pm2
-rw-r--r--perl-install/lvm.pm11
-rw-r--r--perl-install/network/smbnfs.pm4
-rw-r--r--perl-install/partition_table.pm279
-rw-r--r--perl-install/partition_table/bsd.pm2
-rw-r--r--perl-install/partition_table/dos.pm4
-rw-r--r--perl-install/partition_table/gpt.pm4
-rw-r--r--perl-install/partition_table/mac.pm17
-rw-r--r--perl-install/partition_table/sun.pm6
-rw-r--r--perl-install/raid.pm10
25 files changed, 599 insertions, 531 deletions
diff --git a/perl-install/any.pm b/perl-install/any.pm
index fa335a9af..d6ce4ee2f 100644
--- a/perl-install/any.pm
+++ b/perl-install/any.pm
@@ -8,7 +8,8 @@ use strict;
#-######################################################################################
use common;
use detect_devices;
-use partition_table qw(:types);
+use partition_table;
+use fs::type;
use fsedit;
use fs;
use lang;
@@ -265,7 +266,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', pt_type => 'tmpfs' };
+ push @{$all_hds->{special}}, { device => 'none', mntpoint => '/tmp', fs_type => 'tmpfs' };
} else {
@{$all_hds->{special}} = grep { $_->{mntpoint} ne '/tmp' } @{$all_hds->{special}};
}
@@ -481,7 +482,7 @@ sub inspect {
$dir = '';
} else {
mkdir $dir, 0700;
- eval { fs::mount($part->{device}, $dir, type2fs($part, 'skip'), !$b_rw) };
+ eval { fs::mount($part->{device}, $dir, $part->{fs_type}, !$b_rw) };
$@ and return;
}
my $h = before_leaving {
diff --git a/perl-install/bootloader.pm b/perl-install/bootloader.pm
index 62ae0e16e..8481d0445 100644
--- a/perl-install/bootloader.pm
+++ b/perl-install/bootloader.pm
@@ -8,7 +8,8 @@ use vars qw(%vga_modes);
#- misc imports
#-######################################################################################
use common;
-use partition_table qw(:types);
+use partition_table;
+use fs::type;
use log;
use any;
use fsedit;
@@ -583,7 +584,7 @@ sub suggest {
my $root = '/dev/' . (isLoopback($root_part) ? 'loop7' : $root_part->{device});
my $boot = fsedit::get_root($fstab, 'boot')->{device};
#- PPC xfs module requires enlarged initrd
- my $xfsroot = isThisFs("xfs", $root_part);
+ my $xfsroot = $root_part->{fs_type} eq 'xfs';
my ($onmbr, $unsafe) = $bootloader->{crushMbr} ? (1, 0) : suggest_onmbr($hds->[0]);
add2hash_($bootloader, arch() =~ /ppc/ ?
@@ -692,7 +693,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({ pt_type => fsedit::typeOfPart($_->{device}) }) }
+ grep { isFat_or_NTFS($_) && member(fs::type::fs_type_from_magic($_), 'vfat', 'ntfs') }
map { @{$_->{primary}{normal}} } @$hds;
each_index {
add_entry($bootloader,
@@ -910,7 +911,10 @@ sub write_lilo {
my $fstab = [ fsedit::get_fstab(@$hds) ];
(my $part, $file) = fsedit::file2part($fstab, $file);
my %hds = map_index { $_ => "hd$::i" } map { $_->{device} }
- sort { isFat($b) <=> isFat($a) || $a->{device} cmp $b->{device} } @$fstab;
+ sort {
+ my ($a_is_fat, $b_is_fat) = ($a->{fs_type} eq 'vfat', $b->{fs_type} eq 'vfat');
+ $a_is_fat <=> $b_is_fat || $a->{device} cmp $b->{device};
+ } @$fstab;
$hds{$part->{device}} . ":" . $file;
} else {
$file
@@ -1208,8 +1212,8 @@ sub install {
my ($bootloader, $hds) = @_;
if (my $part = fs::device2part($bootloader->{boot}, [ fsedit::get_fstab(@$hds) ])) {
- die N("You can't install the bootloader on a %s partition\n", partition_table::type2fs($part))
- if isThisFs('xfs', $part);
+ die N("You can't install the bootloader on a %s partition\n", $part->{fs_type})
+ if $part->{fs_type} eq 'xfs';
}
$bootloader->{keytable} = keytable($bootloader->{keytable});
action($bootloader, 'install', $hds);
diff --git a/perl-install/diskdrake/dav.pm b/perl-install/diskdrake/dav.pm
index 23652413a..51b6699a1 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 = { pt_type => 'davfs' };
+ my $dav = { fs_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 8479c3f3e..8aff39d06 100644
--- a/perl-install/diskdrake/hd_gtk.pm
+++ b/perl-install/diskdrake/hd_gtk.pm
@@ -5,8 +5,8 @@ use strict;
use common;
use ugtk2 qw(:helpers :wrappers :create);
-use partition_table qw(:types);
-use partition_table::raw;
+use partition_table;
+use fs::type;
use detect_devices;
use diskdrake::interactive;
use run_program;
@@ -292,7 +292,7 @@ sub create_buttons4partitions {
last;
}
});
- $w->set_name("PART_" . part2name($entry));
+ $w->set_name("PART_" . fs::type::part2type_name($entry));
$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 %name2pt_type = (Ext2 => 0x83, 'Journalised FS' => 0x483, Swap => 0x82, Other => 1, "Windows" => 0xb, HFS => 0x402);
+ my %name2fs_type = (Ext2 => 'ext2', 'Journalised FS' => 'ext3', Swap => 'swap', Other => 'other', "Windows" => 'vfat', HFS => 'hfs');
gtkpack(Gtk2::HBox->new(0,0),
N("Filesystem types:"),
map { my $w = Gtk2::Button->new(translate($_));
- my $t = $name2pt_type{$_};
+ my $t = $name2fs_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, $pt_type, $hd, $part, $all_hds) = @_;
+ my ($in, $fs_type, $hd, $part, $all_hds) = @_;
$part ||= !fsedit::get_fstab($hd) &&
{ pt_type => 0, start => 1, size => $hd->{totalsectors} - 1 };
$part or return;
- if ($pt_type == 1) {
+ if ($fs_type eq 'other') {
$in->ask_warn('', N("Use ``%s'' instead", $part->{pt_type} ? N("Type") : N("Create")));
- } elsif (!$pt_type) {
+ } elsif (!$fs_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};
+ return if $fs_type eq $part->{fs_type};
$in->ask_warn('', isBusy($part) ? N("Use ``Unmount'' first") : N("Use ``%s'' instead", N("Type")));
} else {
- $part->{pt_type} = $pt_type;
+ fs::type::set_fs_type($part, $fs_type);
diskdrake::interactive::Create($in, $hd, $part, $all_hds);
}
}
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index f4e73c885..7d0068d29 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -4,7 +4,8 @@ use diagnostics;
use strict;
use common;
-use partition_table qw(:types);
+use fs::type;
+use partition_table;
use partition_table::raw;
use detect_devices;
use run_program;
@@ -26,6 +27,7 @@ struct part {
int start # in sectors
int size # in sectors
int pt_type # 0x82, 0x83, 0x6 ...
+ string fs_type # 'ext2', 'nfs', ...
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 +146,7 @@ struct hd_lvm inherits hd {
}
struct raw_hd inherits hd {
- string pt_type # 0x82, 0x83, 'nfs', ...
+ string fs_type # 'ext2', 'nfs', ...
string mntpoint # '/', '/usr' ...
string options # 'defaults', 'noauto'
@@ -411,9 +413,9 @@ 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->{pt_type} & 0xff) == 0x83)',
+ N_("Type") => '!isBusy && $::expert && (!readonly || $part->{pt_type} == 0x83)',
N_("Options") => '$::expert',
- N_("Resize") => '!isBusy && !readonly && !isSpecial || isLVM($hd) && isMounted && isThisFs("xfs", $part)',
+ N_("Resize") => '!isBusy && !readonly && !isSpecial || isLVM($hd) && isMounted && $part->{fs_type} eq "xfs"',
N_("Move") => '!isBusy && !readonly && !isSpecial && $::expert && 0', # disable for the moment
N_("Format") => '!isBusy && !readonly && ($::expert || $::isStandalone)',
N_("Mount") => '!isBusy && (hasMntpoint || isSwap) && maybeFormatted && ($::expert || $::isStandalone)',
@@ -453,14 +455,14 @@ sub Create {
$part->{maxsize} = $part->{size}; $part->{size} = 0;
if (!fsedit::suggest_part($part, $all_hds)) {
$part->{size} = $part->{maxsize};
- $part->{pt_type} ||= 0x483;
+ fs::type::suggest_fs_type($part, 'ext3');
}
#- 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_name = part2name($part);
+ my $type_name = fs::type::part2type_name($part);
my $mb_size = $part->{size} >> 11;
my $has_startsector = ($::expert || arch() !~ /i.86/) && !isLVM($hd);
@@ -470,9 +472,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_name, list => [ partition_table::important_types() ], sort => 0 },
+ { label => N("Filesystem type: "), val => \$type_name, list => [ fs::type::type_names() ], sort => 0 },
{ label => N("Mount point: "), val => \$part->{mntpoint}, list => [ fsedit::suggestions_mntpoint($all_hds), '' ],
- disabled => sub { my $p = { pt_type => name2pt_type($type_name) }; isSwap($p) || isNonMountable($p) }, type => 'combo', not_edit => 0,
+ disabled => sub { my $p = fs::type::type_name2subpart($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 +494,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->{pt_type} = name2pt_type($type_name);
+ put_in_hash($part, fs::type::type_name2subpart($type_name));
$part->{mntpoint} = '' if isNonMountable($part);
$part->{mntpoint} = 'swap' if isSwap($part);
fs::set_default_options($part);
@@ -559,27 +561,28 @@ sub Type {
my $warn = sub { ask_alldatawillbelost($in, $part, N_("After changing type of partition %s, all data on this partition will be lost")) };
#- for ext2, warn after choosing as ext2->ext3 can be achieved without loosing any data :)
- isExt2($part) or $warn->() or return;
+ $part->{fs_type} eq 'ext2' or $warn->() or return;
- my @types = partition_table::important_types();
+ my @types = fs::type::type_names();
- #- when readonly, Type() is allowed only when changing between various { 0x83, 0x183, ... }
- @types = grep { (name2pt_type($_) & 0xff) == 0x83 } @types if $hd->{readonly};
+ #- when readonly, Type() is allowed only when changing {fs_type} but not {pt_type}
+ #- eg: switching between ext2, ext3, reiserfs...
+ @types = grep { fs::type::type_name2pt_type($_) == $part->{pt_type} } @types if $hd->{readonly};
- my $type_name = part2name($part);
+ my $type_name = fs::type::part2type_name($part);
$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 $pt_type = $type_name && name2pt_type($type_name);
+ my $type = $type_name && fs::type::type_name2subpart($type_name);
- if (isExt2($part) && isThisFs('ext3', { pt_type => $pt_type })) {
+ if (member($type->{fs_type}, 'ext2', 'ext3')) {
my $_w = $in->wait_message('', N("Switching from ext2 to ext3"));
if (run_program::run("tune2fs", "-j", devices::make($part->{device}))) {
- $part->{pt_type} = $pt_type;
- $part->{isFormatted} = 1; #- assume that if tune2fs works, partition is formatted
+ put_in_hash($part, $type);
+ set_isFormatted($part, 1); #- assume that if tune2fs works, partition is formatted
#- disable the fsck (don't do it together with -j in case -j fails?)
fs::format::disable_forced_fsck($part->{device});
@@ -587,10 +590,10 @@ sub Type {
}
}
#- either we switch to non-ext3 or switching losslessly to ext3 failed
- !isExt2($part) or $warn->() or return;
+ $part->{fs_type} ne 'ext2' or $warn->() or return;
- if (defined $pt_type) {
- check_pt_type($in, $pt_type, $hd, $part) and fsedit::change_pt_type($pt_type, $hd, $part);
+ if (defined $type) {
+ check_type($in, $type, $hd, $part) and fsedit::change_type($type, $hd, $part);
}
}
@@ -657,7 +660,7 @@ sub Resize {
# here we may have a non-formatted or a formatted partition
# -> doing as if it was formatted
- if (isFat($part)) {
+ if ($part->{fs_type} eq 'vfat') {
write_partitions($in, $hd) or return;
#- try to resize without losing data
my $_w = $in->wait_message(N("Resizing"), N("Computing FAT filesystem bounds"));
@@ -666,7 +669,7 @@ sub Resize {
$nice_resize{fat} = resize_fat::main->new($part->{device}, devices::make($part->{device}));
$min = max($min, $nice_resize{fat}->min_size);
$max = min($max, $nice_resize{fat}->max_size);
- } elsif (isExt2($part) || isThisFs('ext3', $part)) {
+ } elsif (member($part->{fs_type}, 'ext2', 'ext3')) {
write_partitions($in, $hd) or return;
my $dev = devices::make($part->{device});
my $r = run_program::get_stdout('dumpe2fs', $dev);
@@ -678,18 +681,18 @@ sub Resize {
$min = max($min, ($block_count - $free_block) * ($block_size / 512));
$nice_resize{ext2} = $dev;
}
- } elsif (isThisFs('ntfs', $part)) {
+ } elsif ($part->{fs_type} eq 'ntfs') {
write_partitions($in, $hd) or return;
require diskdrake::resize_ntfs;
$nice_resize{ntfs} = diskdrake::resize_ntfs->new($part->{device}, devices::make($part->{device}));
$min = $nice_resize{ntfs}->min_size or delete $nice_resize{ntfs};
- } elsif (isThisFs("reiserfs", $part)) {
+ } elsif ($part->{fs_type} eq 'reiserfs') {
write_partitions($in, $hd) or return;
if (defined(my $free = fs::df($part))) {
$nice_resize{reiserfs} = 1;
$min = max($min, $part->{size} - $free);
}
- } elsif (isThisFs('xfs', $part) && isLVM($hd) && $::isStandalone && isMounted($part)) {
+ } elsif ($part->{fs_type} eq 'xfs' && isLVM($hd) && $::isStandalone && $part->{isMounted}) {
$min = $part->{size}; #- ensure the user can only increase
$nice_resize{xfs} = 1;
}
@@ -764,10 +767,9 @@ filesystem checks will be run on your next boot into Windows(TM)"));
}
if (%nice_resize) {
- $part->{isFormatted} = 1;
+ set_isFormatted($part, 1);
} else {
- $part->{notFormatted} = 1;
- $part->{isFormatted} = 0;
+ set_isFormatted($part, 0);
partition_table::verifyParts($hd);
$part->{mntpoint} = '' if isNonMountable($part); #- mainly for ntfs, which we can't format
}
@@ -866,20 +868,20 @@ sub Loopback {
my $handle = any::inspect($real_part) or $in->ask_warn('', N("This partition can't be used for loopback")), return;
my ($min, $max) = (1, loopback::getFree($handle->{dir}, $real_part));
- $max = min($max, 1 << (31 - 9)) if isFat($real_part); #- FAT doesn't handle file size bigger than 2GB
+ $max = min($max, 1 << (31 - 9)) if $real_part->{fs_type} eq 'vfat'; #- FAT doesn't handle file size bigger than 2GB
my $part = { maxsize => $max, size => 0, loopback_device => $real_part, notFormatted => 1 };
if (!fsedit::suggest_part($part, $all_hds)) {
$part->{size} = $part->{maxsize};
- $part->{pt_type} ||= 0x483;
+ fs::type::suggest_fs_type($part, 'ext3');
}
delete $part->{mntpoint}; # we don't want the suggested mntpoint
- my $type_name = part2name($part);
+ my $type_name = fs::type::part2type_name($part);
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_name, list => [ partition_table::important_types() ], not_edit => !$::expert, sort => 0 },
+ { label => N("Filesystem type: "), val => \$type_name, list => [ fs::type::type_names() ], not_edit => !$::expert, sort => 0 },
],
complete => sub {
$part->{loopback_file} or $in->ask_warn('', N("Give a file name")), return 1, 0;
@@ -894,7 +896,7 @@ sub Loopback {
}
0;
}) or return;
- $part->{pt_type} = name2pt_type($type_name);
+ put_in_hash($part, fs::type::type_name2subpart($type_name));
push @{$real_part->{loopback}}, $part;
fsedit::recompute_loopbacks($all_hds);
}
@@ -1018,21 +1020,20 @@ sub partitions_suggestions {
$fsedit::suggestions{$t};
}
-sub check_pt_type {
- my ($in, $pt_type, $hd, $part) = @_;
- eval { fsedit::check_pt_type($pt_type, $hd, $part) };
+sub check_type {
+ my ($in, $type, $hd, $part) = @_;
+ eval { fsedit::check_fs_type($type->{fs_type}, $hd, $part) };
if (my $err = $@) {
$in->ask_warn('', formatError($err));
return;
}
if ($::isStandalone) {
- 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") {
+ if (my $pkg = fsedit::package_needed_for_partition_type($type)) {
+ if (!-x "/sbin/mkfs.$type->{fs_type}") {
$in->ask_yesorno('', N("The package %s is needed. Install it?", $pkg), 1) or return;
$in->do_pkgs->install($pkg);
}
- -x "/sbin/mkfs.$fs" or $in->ask_warn('', "Mandatory package $pkg is missing"), return;
+ -x "/sbin/mkfs.$type->{fs_type}" or $in->ask_warn('', "Mandatory package $pkg is missing"), return;
}
}
1;
@@ -1052,7 +1053,7 @@ sub check_mntpoint {
}
sub check {
my ($in, $hd, $part, $all_hds) = @_;
- check_pt_type($in, $part->{pt_type}, $hd, $part) &&
+ check_type($in, $part, $hd, $part) &&
check_mntpoint($in, $part->{mntpoint}, $hd, $part, $all_hds);
}
@@ -1157,17 +1158,16 @@ sub format_part_info {
$info .= N("Volume label: ") . "$part->{device_LABEL}\n" if $part->{device_LABEL} && $::expert;
$info .= N("DOS drive letter: %s (just a guess)\n", $part->{device_windobe}) if $part->{device_windobe};
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->{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";
- }
+ my $pType = $part->{pType};
+ $pType =~ s/[^A-Za-z0-9_]//g;
+ $info .= N("Type: ") . $pType . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n";
+ if (defined $part->{pName}) {
+ my $pName = $part->{pName};
+ $pName =~ s/[^A-Za-z0-9_]//g;
+ $info .= N("Name: ") . $pName . "\n";
+ }
} elsif ($part->{pt_type}) {
- my $type_name = substr(part2name($part), 0, 40); # limit the length
- $info .= N("Type: ") . $type_name . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n";
+ $info .= N("Type: ") . (fs::type::part2type_name($part) || $part->{fs_type}) . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n";
} else {
$info .= N("Empty") . "\n";
}
@@ -1232,8 +1232,7 @@ sub format_raw_hd_info {
$info .= N("Mount point: ") . "$raw_hd->{mntpoint}\n" if $raw_hd->{mntpoint};
$info .= format_hd_info($raw_hd);
if ($raw_hd->{pt_type}) {
- my $type_name = substr(part2name($raw_hd), 0, 40); # limit the length
- $info .= N("Type: ") . $type_name . "\n";
+ $info .= N("Type: ") . (fs::type::part2type_name($raw_hd) || $raw_hd->{fs_type}) . "\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 905f6a2c4..d2c7ad32c 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 $pt_type = $raw_hd->{pt_type};
+ my $fs_type = $raw_hd->{fs_type};
$in->ask_from(N("Change type"),
N("Which filesystem do you want?"),
- [ { label => N("Type"), val => \$pt_type, list => [@fs], not_edit => !$::expert } ]) or return;
- $raw_hd->{pt_type} = $pt_type;
+ [ { label => N("Type"), val => \$fs_type, list => [@fs], not_edit => !$::expert } ]) or return;
+ $raw_hd->{fs_type} = $fs_type;
}
1;
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index efd1502db..4614d7d20 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -8,7 +8,7 @@ use MDK::Common::Various;
use common;
use log;
use devices;
-use partition_table qw(:types);
+use fs::type;
use run_program;
use detect_devices;
use modules;
@@ -46,12 +46,11 @@ sub read_fstab {
$options = 'defaults' if $options eq 'rw'; # clean-up for mtab read
- my $pt_type = fs2pt_type($fs_type);
- if ($pt_type eq 'supermount') {
+ if ($fs_type eq 'supermount') {
# normalize this bloody supermount
$options = join(",", 'supermount', grep {
if (/fs=(.*)/) {
- $pt_type = $1;
+ $fs_type = $1;
0;
} elsif (/dev=(.*)/) {
$dev = $1;
@@ -62,15 +61,15 @@ sub read_fstab {
1;
}
} split(',', $options));
- } elsif ($pt_type eq 'smb') {
+ } elsif ($fs_type eq 'smb') {
# prefering type "smbfs" over "smb"
- $pt_type = 'smbfs';
+ $fs_type = 'smbfs';
}
$mntpoint =~ s/\\040/ /g;
$dev =~ s/\\040/ /g;
my $h = {
- mntpoint => $mntpoint, pt_type => $pt_type,
+ mntpoint => $mntpoint, fs_type => $fs_type,
options => $options, comment => $comment,
if_(member('keep_freq_passno', @reading_options), freq => $freq, passno => $passno),
};
@@ -110,16 +109,15 @@ sub merge_fstabs {
$p->{mntpoint} = $p2->{mntpoint} if delete $p->{unsafeMntpoint};
- $p->{pt_type} = $p2->{pt_type} if $p2->{pt_type} && !$loose;
+ $p->{fs_type} = $p2->{fs_type} if $p2->{fs_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->{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) || part2name($p)) . " vs ", (type2fs($p2) || part2name($p2)));
+ $p->{fs_type} && $p2->{fs_type} && $p->{fs_type} ne $p2->{fs_type}
+ && $p->{fs_type} ne 'auto' && $p2->{fs_type} ne 'auto' and
+ log::l("err, fstab and partition table do not agree for $p->{device} type: $p->{fs_type} vs $p2->{fs_type}");
}
@l;
}
@@ -180,9 +178,9 @@ sub add2all_hds {
foreach (@l) {
my $s =
- isThisFs('nfs', $_) ? 'nfss' :
- isThisFs('smbfs', $_) ? 'smbs' :
- isThisFs('davfs', $_) ? 'davs' :
+ $_->{fs_type} eq 'nfs' ? 'nfss' :
+ $_->{fs_type} eq 'smbfs' ? 'smbs' :
+ $_->{fs_type} eq 'davfs' ? 'davs' :
isTrueLocalFS($_) || isSwap($_) || isOtherAvailableFS($_) ? '' :
'special';
push @{$all_hds->{$s}}, $_ if $s;
@@ -200,9 +198,9 @@ sub merge_info_from_mtab {
my ($fstab) = @_;
my @l1 = map { my $l = $_;
- my %l = (pt_type => fs2pt_type('swap'));
- $l{$_} = $l->{$_} foreach qw(device major minor);
- \%l;
+ my $h = fs::type::fs_type2subpart('swap');
+ $h->{$_} = $l->{$_} foreach qw(device major minor);
+ $h;
} read_fstab('', '/proc/swaps');
my @l2 = map { read_fstab('', $_) } '/etc/mtab', '/proc/mounts';
@@ -216,7 +214,8 @@ sub merge_info_from_mtab {
$_->{mntpoint} = common::usingRamdisk() && "/mnt/hd"; #- remap for hd install.
}
}
- $_->{isMounted} = $_->{isFormatted} = 1;
+ $_->{isMounted} = 1;
+ set_isFormatted($_, 1);
delete $_->{options};
}
merge_fstabs('loose', $fstab, @l1, @l2);
@@ -255,7 +254,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}, $_->{pt_type});
+ part2device($o_prefix, $_->{prefer_devfs_name} ? $_->{devfs_device} : $_->{device}, $_->{fs_type});
my $real_mntpoint = $_->{mntpoint} || ${{ '/tmp/hdimage' => '/mnt/hd' }}{$_->{real_mntpoint}};
mkdir_p("$o_prefix$real_mntpoint") if $real_mntpoint =~ m|^/|;
@@ -275,7 +274,7 @@ sub prepare_write_fstab {
my $options = $_->{options};
- if (isThisFs('smbfs', $_) && $options =~ /password=/ && !$b_keep_smb_credentials) {
+ if ($_->{fs_type} eq 'smbfs' && $options =~ /password=/ && !$b_keep_smb_credentials) {
require network::smb;
if (my ($opts, $smb_credentials) = network::smb::fstab_entry_to_credentials($_)) {
$options = $opts;
@@ -283,7 +282,7 @@ sub prepare_write_fstab {
}
}
- my $fs_type = type2fs($_, 'auto');
+ my $fs_type = $_->{fs_type} || 'auto';
my $dev =
$_->{prefer_device_LABEL} ? 'LABEL=' . $_->{device_LABEL} :
@@ -309,7 +308,7 @@ sub prepare_write_fstab {
} else {
()
}
- } grep { $_->{device} && ($_->{mntpoint} || $_->{real_mntpoint}) && $_->{pt_type} && ($_->{isFormatted} || !$_->{notFormatted}) } @$fstab;
+ } grep { $_->{device} && ($_->{mntpoint} || $_->{real_mntpoint}) && $_->{fs_type} && ($_->{isFormatted} || !$_->{notFormatted}) } @$fstab;
join('', map { $_->[1] } sort { $a->[0] cmp $b->[0] } @l), \@smb_credentials;
}
@@ -331,8 +330,8 @@ sub write_fstab {
}
sub part2device {
- my ($prefix, $dev, $pt_type) = @_;
- $dev eq 'none' || member($pt_type, qw(nfs smbfs davfs)) ?
+ my ($prefix, $dev, $fs_type) = @_;
+ $dev eq 'none' || member($fs_type, qw(nfs smbfs davfs)) ?
$dev :
do {
my $dir = $dev =~ m!^(/|LABEL=)! ? '' : '/dev/';
@@ -373,13 +372,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->{pt_type} eq 'auto' && member($fs, @auto_fs) or next;
+ $part->{fs_type} eq $fs || $part->{fs_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->{pt_type} =~ /:/ || member(type2fs($part), 'auto', @auto_fs);
+ $non_defaults->{supermount} = 1 if $part->{fs_type} =~ /:/ || member($part->{fs_type}, 'auto', @auto_fs);
my $defaults = { reverse %$non_defaults };
my %options = map { $_ => '' } keys %$non_defaults;
@@ -489,7 +488,7 @@ sub rationalize_options {
my ($options, $unknown) = mount_options_unpack($part);
- if (!isThisFs('reiserfs', $part)) {
+ if ($part->{fs_type} ne 'reiserfs') {
$options->{notail} = 0;
}
@@ -504,8 +503,8 @@ sub set_default_options {
if ($part->{is_removable}) {
$options->{supermount} = $opts{useSupermount} && !($opts{useSupermount} eq 'magicdev' && $part->{media_type} eq 'cdrom');
- $part->{pt_type} = !$options->{supermount} ? 'auto' :
- $part->{media_type} eq 'cdrom' ? 'udf:iso9660' : 'ext2:vfat';
+ $part->{fs_type} = !$options->{supermount} ? 'auto' :
+ $part->{media_type} eq 'cdrom' ? 'udf:iso9660' : 'ext2:vfat';
}
if ($part->{media_type} eq 'cdrom') {
@@ -524,15 +523,15 @@ sub set_default_options {
#- news spool to speed up news servers).
$options->{noatime} = detect_devices::isLaptop();
}
- if (isThisFs('nfs', $part)) {
+ if ($part->{fs_type} eq 'nfs') {
put_in_hash($options, {
nosuid => 1, 'rsize=8192,wsize=8192' => 1, soft => 1,
});
}
- if (isThisFs('smbfs', $part)) {
+ if ($part->{fs_type} eq 'smbfs') {
add2hash($options, { 'username=' => '%' }) if !$options->{'credentials='};
}
- if (isFat($part) || member('vfat', split(':', $part->{pt_type})) || isThisFs('auto', $part)) {
+ if (member('vfat', split(':', $part->{fs_type})) || $part->{fs_type} eq 'auto') {
put_in_hash($options, {
user => 1, noexec => 0,
@@ -543,15 +542,15 @@ sub set_default_options {
'iocharset=' => $opts{iocharset}, 'codepage=' => $opts{codepage},
});
}
- if (isThisFs('ntfs', $part)) {
+ if ($part->{fs_type} eq 'ntfs') {
put_in_hash($options, { ro => 1, 'nls=' => $opts{iocharset},
'umask=0' => $opts{security} < 3, 'umask=0022' => $opts{security} < 4,
});
}
- if (member('iso9660', split(':', $part->{pt_type})) || isThisFs('auto', $part)) {
+ if (member('iso9660', split(':', $part->{fs_type})) || $part->{fs_type} eq 'auto') {
put_in_hash($options, { user => 1, noexec => 0, 'iocharset=' => $opts{iocharset} });
}
- if (isThisFs('reiserfs', $part)) {
+ if ($part->{fs_type} eq 'reiserfs') {
$options->{notail} = 1;
}
if (isLoopback($part) && !isSwap($part)) { #- no need for loop option for swap files
@@ -607,13 +606,13 @@ sub get_raw_hds {
get_major_minor(@{$all_hds->{raw_hds}});
my @fstab = read_fstab($prefix, '/etc/fstab', 'keep_default');
- $all_hds->{nfss} = [ grep { isThisFs('nfs', $_) } @fstab ];
- $all_hds->{smbs} = [ grep { isThisFs('smbfs', $_) } @fstab ];
- $all_hds->{davs} = [ grep { isThisFs('davfs', $_) } @fstab ];
+ $all_hds->{nfss} = [ grep { $_->{fs_type} eq 'nfs' } @fstab ];
+ $all_hds->{smbs} = [ grep { $_->{fs_type} eq 'smbfs' } @fstab ];
+ $all_hds->{davs} = [ grep { $_->{fs_type} eq 'davfs' } @fstab ];
$all_hds->{special} = [
- (grep { isThisFs('tmpfs', $_) } @fstab),
- { device => 'none', mntpoint => '/proc', pt_type => 'proc' },
- { device => 'none', mntpoint => '/dev/pts', pt_type => 'devpts', options => 'mode=0620' },
+ (grep { $_->{fs_type} eq 'tmpfs' } @fstab),
+ { device => 'none', mntpoint => '/proc', fs_type => 'proc' },
+ { device => 'none', mntpoint => '/dev/pts', fs_type => 'devpts', options => 'mode=0620' },
];
}
@@ -676,7 +675,7 @@ sub mount {
$dev = part2device('', $dev, $fs);
- $fs ne 'skip' or log::l("not mounting $dev partition"), return;
+ $fs or log::l("not mounting $dev partition"), return;
my @fs_modules = qw(vfat hfs romfs ufs reiserfs xfs jfs ext3);
@@ -791,11 +790,12 @@ sub mount_part {
$mntpoint = "/initrd/loopfs";
}
my $dev = $part->{real_device} || $part->{device};
- mount($dev, $mntpoint, type2fs($part, 'skip'), $b_rdonly, $part->{options}, $o_wait_message);
+ mount($dev, $mntpoint, $part->{fs_type}, $b_rdonly, $part->{options}, $o_wait_message);
rmdir "$mntpoint/lost+found";
}
}
- $part->{isMounted} = $part->{isFormatted} = 1; #- assume that if mount works, partition is formatted
+ $part->{isMounted} = 1;
+ set_isFormatted($part, 1); #- assume that if mount works, partition is formatted
}
sub umount_part {
@@ -841,10 +841,9 @@ sub df {
return; #- won't even try!
} else {
mkdir_p($dir);
- eval { mount($part->{device}, $dir, type2fs($part, 'skip'), 'readonly') };
+ eval { mount($part->{device}, $dir, $part->{fs_type}, 'readonly') };
if ($@) {
- $part->{notFormatted} = 1;
- $part->{isFormatted} = 0;
+ set_isFormatted($part, 0);
unlink $dir;
return;
}
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
index a3a33f0c4..d41a98ccc 100644
--- a/perl-install/fs/format.pm
+++ b/perl-install/fs/format.pm
@@ -1,9 +1,12 @@
package fs::format;
+use diagnostics;
+use strict;
+
use run_program;
use common;
+use fs::type;
use log;
-use partition_table qw(:types);
my %cmds = (
ext2 => 'mke2fs -F',
@@ -44,9 +47,9 @@ sub part_raw {
my $dev = $part->{real_device} || $part->{device};
my @options = if_($part->{toFormatCheck}, "-c");
- log::l("formatting device $dev (type ", part2name($part), ")");
+ log::l("formatting device $dev (type $part->{fs_type})");
- my $fs_type = type2fs($part);
+ my $fs_type = $part->{fs_type};
if ($fs_type eq 'ext2' || $fs_type eq 'ext3') {
push @options, "-m", "0" if $part->{mntpoint} =~ m|^/home|;
@@ -58,7 +61,7 @@ sub part_raw {
push @options, '-l', 'bootstrap';
}
- my $cmd = $cmds{$fs_type} or die N("I don't know how to format %s in type %s", $part->{device}, part2name($part));
+ my $cmd = $cmds{$fs_type} or die N("I don't know how to format %s in type %s", $part->{device}, $part->{fs_type});
run_program::raw({ timeout => 60 * 60 }, split(' ', $cmd), @options, devices::make($dev)) or die N("%s formatting of %s failed", $fs_type, $dev);
@@ -66,7 +69,7 @@ sub part_raw {
disable_forced_fsck($dev);
}
- $part->{isFormatted} = 1;
+ set_isFormatted($part, 1);
}
sub disable_forced_fsck {
diff --git a/perl-install/fs/type.pm b/perl-install/fs/type.pm
new file mode 100644
index 000000000..90d2f3ad0
--- /dev/null
+++ b/perl-install/fs/type.pm
@@ -0,0 +1,334 @@
+package fs::type; # $Id$
+
+use diagnostics;
+use strict;
+
+use common;
+
+
+our @ISA = qw(Exporter);
+our @EXPORT = qw(
+ isExtended isTrueLocalFS isTrueFS isDos isSwap isSunOS isOtherAvailableFS isRawLVM isRawRAID isRAID isLVM isMountableRW isNonMountable isPartOfLVM isPartOfRAID isPartOfLoopback isLoopback isMounted isBusy isSpecial isApple isAppleBootstrap isWholedisk isHiddenMacPart isFat_or_NTFS
+ maybeFormatted set_isFormatted
+);
+
+
+my (%type_name2pt_type, %type_name2fs_type, %fs_type2pt_type, %pt_type2fs_type, %type_names);
+
+{
+ my @list_types = (
+ important => [
+ 0x82 => 'swap', 'Linux swap',
+ 0x83 => 'ext2', 'Linux native',
+ 0x83 => 'ext3', 'Journalised FS: ext3',
+ 0x83 => 'reiserfs', 'Journalised FS: ReiserFS',
+if_(arch() =~ /ppc|i.86|ia64/,
+ 0x83 => 'xfs', 'Journalised FS: XFS',
+),
+if_(arch() =~ /ppc|i.86/,
+ 0x83 => 'jfs', 'Journalised FS: JFS',
+),
+if_(arch() =~ /i.86|ia64|x86_64/,
+ 0x0b => 'vfat', 'FAT32',
+),
+if_(arch() =~ /ppc/,
+ 0x401 => 'apple', 'Apple Bootstrap',
+ 0x402 => 'hfs', 'Apple HFS Partition',
+),
+ ],
+
+ less_important => [
+ 0x8e => '', 'Linux Logical Volume Manager',
+ 0xfd => '', 'Linux RAID',
+ ],
+
+ special => [
+ 0x0 => '', 'Empty',
+ 0x05 => '', 'Extended',
+ 0x0f => '', 'W95 Extended (LBA)',
+ 0x85 => '', 'Linux extended',
+ ],
+
+ backward_compatibility => [
+ 0x183 => 'reiserfs', 'reiserfs (deprecated)',
+ 0x283 => 'xfs', 'xfs (deprecated)',
+ 0x383 => 'jfs', 'jfs (deprecated)',
+ 0x483 => 'ext3', 'ext3 (deprecated)',
+ ],
+
+ other => [
+ if_(arch() =~ /^ia64/,
+ 0x100 => '', 'Various',
+), if_(arch() =~ /^ppc/,
+ 0x401 => 'apple', 'Apple Partition',
+), if_(arch() =~ /^sparc/,
+ 0x01 => 'ufs', 'SunOS boot',
+ 0x02 => 'ufs', 'SunOS root',
+ 0x03 => 'ufs', 'SunOS swap',
+ 0x04 => 'ufs', 'SunOS usr',
+ 0x05 => 'ufs', 'Whole disk',
+ 0x06 => 'ufs', 'SunOS stand',
+ 0x07 => 'ufs', 'SunOS var',
+ 0x08 => 'ufs', 'SunOS home',
+), if_(arch() =~ /^i.86/,
+ 0x01 => 'vfat', 'FAT12',
+ 0x02 => '', 'XENIX root',
+ 0x03 => '', 'XENIX usr',
+ 0x04 => 'vfat', 'FAT16 <32M',
+ 0x06 => 'vfat', 'FAT16',
+ 0x07 => (arch() =~ /^ppc/ ? 'hpfs' : 'ntfs'), 'NTFS (or HPFS)',
+ 0x08 => '', 'AIX',
+),
+ 0x09 => '', 'AIX bootable',
+ 0x0a => '', 'OS/2 Boot Manager',
+ 0x0c => 'vfat', 'W95 FAT32 (LBA)',
+ 0x0e => 'vfat', 'W95 FAT16 (LBA)',
+ 0x10 => '', 'OPUS',
+ 0x11 => '', 'Hidden FAT12',
+ 0x12 => '', 'Compaq diagnostics',
+ 0x14 => '', 'Hidden FAT16 <32M',
+ 0x16 => '', 'Hidden FAT16',
+ 0x17 => 'ntfs', 'Hidden HPFS/NTFS',
+ 0x18 => '', 'AST SmartSleep',
+ 0x1b => 'vfat', 'Hidden W95 FAT32',
+ 0x1c => 'vfat', 'Hidden W95 FAT32 (LBA)',
+ 0x1e => 'vfat', 'Hidden W95 FAT16 (LBA)',
+ 0x24 => '', 'NEC DOS',
+ 0x39 => '', 'Plan 9',
+ 0x3c => '', 'PartitionMagic recovery',
+ 0x40 => '', 'Venix 80286',
+ 0x41 => '', 'PPC PReP Boot',
+ 0x42 => '', 'SFS',
+ 0x4d => '', 'QNX4.x',
+ 0x4e => '', 'QNX4.x 2nd part',
+ 0x4f => '', 'QNX4.x 3rd part',
+ 0x50 => '', 'OnTrack DM',
+ 0x51 => '', 'OnTrack DM6 Aux1',
+ 0x52 => '', 'CP/M',
+ 0x53 => '', 'OnTrack DM6 Aux3',
+ 0x54 => '', 'OnTrackDM6',
+ 0x55 => '', 'EZ-Drive',
+ 0x56 => '', 'Golden Bow',
+ 0x5c => '', 'Priam Edisk',
+ 0x61 => '', 'SpeedStor',
+ 0x63 => '', 'GNU HURD or SysV',
+ 0x64 => '', 'Novell Netware 286',
+ 0x65 => '', 'Novell Netware 386',
+ 0x70 => '', 'DiskSecure Multi-Boot',
+ 0x75 => '', 'PC/IX',
+ 0x80 => '', 'Old Minix',
+ 0x81 => '', 'Minix / old Linux',
+ 0x84 => '', 'OS/2 hidden C: drive',
+ 0x86 => '', 'NTFS volume set',
+ 0x87 => '', 'NTFS volume set ',
+ 0x93 => '', 'Amoeba',
+ 0x94 => '', 'Amoeba BBT',
+ 0x9f => '', 'BSD/OS',
+ 0xa0 => '', 'IBM Thinkpad hibernation',
+ 0xa5 => '', 'FreeBSD',
+ 0xa6 => '', 'OpenBSD',
+ 0xa7 => '', 'NeXTSTEP',
+ 0xa8 => '', 'Darwin UFS',
+ 0xa9 => '', 'NetBSD',
+ 0xab => '', 'Darwin boot',
+ 0xb7 => '', 'BSDI fs',
+ 0xb8 => '', 'BSDI swap',
+ 0xbb => '', 'Boot Wizard hidden',
+ 0xbe => '', 'Solaris boot',
+ 0xc1 => '', 'DRDOS/sec (FAT-12)',
+ 0xc4 => '', 'DRDOS/sec (FAT-16 < 32M)',
+ 0xc6 => '', 'DRDOS/sec (FAT-16)',
+ 0xc7 => '', 'Syrinx',
+ 0xda => '', 'Non-FS data',
+ 0xdb => '', 'CP/M / CTOS / ...',
+ 0xde => '', 'Dell Utility',
+ 0xdf => '', 'BootIt',
+ 0xe1 => '', 'SpeedStor (FAT-12)',
+ 0xe3 => '', 'DOS R/O',
+ 0xe4 => '', 'SpeedStor (FAT-16)',
+ 0xeb => 'befs', 'BeOS fs',
+ 0xee => '', 'EFI GPT',
+ 0xef => 'vfat', 'EFI (FAT-12/16/32)',
+ 0xf0 => '', 'Linux/PA-RISC boot',
+ 0xf4 => '', 'SpeedStor (large part.)',
+ 0xf2 => '', 'DOS secondary',
+ 0xfe => '', 'LANstep',
+ 0xff => '', 'BBT',
+ ],
+ );
+
+ foreach (group_by2(@list_types)) {
+ my ($name, $l) = @$_;
+ for (my $i = 0; defined $l->[$i]; $i += 3) {
+ my $pt_type = $l->[$i];
+ my $fs_type = $l->[$i + 1];
+ my $type_name = $l->[$i + 2];
+ !exists $type_name2fs_type{$type_name} or internal_error("'$type_name' is not unique");
+ $type_name2fs_type{$type_name} = $fs_type;
+ $type_name2pt_type{$type_name} = $pt_type;
+
+ $fs_type2pt_type{$fs_type} ||= $pt_type;
+ $pt_type2fs_type{$pt_type} ||= $fs_type;
+ push @{$type_names{$name}}, $type_name;
+ }
+ }
+}
+
+
+sub type_names() {
+ my @l = @{$type_names{important}};
+ push @l, @{$type_names{less_important}}, sort @{$type_names{other}} if $::expert;
+ @l;
+}
+
+sub type_name2subpart {
+ my ($name) = @_;
+ exists $type_name2fs_type{$name} &&
+ { fs_type => $type_name2fs_type{$name}, pt_type => $type_name2pt_type{$name} };
+}
+
+sub part2type_name {
+ my ($part) = @_;
+ my @names = keys %type_name2fs_type;
+ if (exists $part->{pt_type}) {
+ @names = grep { $part->{pt_type} eq $type_name2pt_type{$_} } @names;
+ }
+ if ($part->{fs_type}) {
+ @names = grep { $part->{fs_type} eq $type_name2fs_type{$_} } @names;
+ }
+
+ if (@names > 1) {
+ log::l("ERROR: (part2type_name) multiple match for $part->{pt_type} $part->{fs_type}");
+ }
+ first(@names);
+}
+sub type_name2pt_type {
+ local ($_) = @_;
+ /0x(.*)/ ? hex $1 : $type_name2pt_type{$_} || $_;
+}
+
+
+sub pt_type2subpart {
+ my ($pt_type) = @_;
+ my $fs_type = $pt_type2fs_type{$pt_type};
+ { pt_type => $pt_type, if_($fs_type, fs_type => $fs_type) };
+}
+sub fs_type2subpart {
+ my ($fs_type) = @_;
+ my $pt_type = $fs_type2pt_type{$fs_type};
+ { fs_type => $fs_type, if_($pt_type, pt_type => $pt_type) };
+}
+sub set_fs_type {
+ my ($part, $fs_type) = @_;
+ put_in_hash($part, fs_type2subpart($fs_type));
+}
+sub set_pt_type {
+ my ($part, $pt_type) = @_;
+ put_in_hash($part, pt_type2subpart($pt_type));
+}
+sub suggest_fs_type {
+ my ($part, $fs_type) = @_;
+ set_fs_type($part, $fs_type) if !$part->{pt_type} && !$part->{fs_type};
+}
+sub set_type_subpart {
+ my ($part, $subpart) = @_;
+ if (exists $subpart->{pt_type} && exists $subpart->{fs_type}) {
+ $part->{fs_type} = $subpart->{fs_type};
+ $part->{pt_type} = $subpart->{pt_type};
+ } elsif (exists $subpart->{pt_type}) {
+ set_pt_type($part, $subpart->{pt_type});
+ } elsif (exists $subpart->{fs_type}) {
+ set_pt_type($part, $subpart->{fs_type});
+ } else {
+ log::l("ERROR: (set_type_subpart) subpart has no type");
+ }
+}
+
+
+my @partitions_signatures = (
+ [ 'Linux Logical Volume Manager', 0, "HM\1\0" ],
+ [ 'ext2', 0x438, "\x53\xEF" ],
+ [ 'reiserfs', 0x10034, "ReIsErFs" ],
+ [ 'reiserfs', 0x10034, "ReIsEr2Fs" ],
+ [ 'xfs', 0, 'XFSB', 0x200, 'XAGF', 0x400, 'XAGI' ],
+ [ 'jfs', 0x8000, 'JFS1' ],
+ [ 'swap', 4086, "SWAP-SPACE" ],
+ [ 'swap', 4086, "SWAPSPACE2" ],
+ [ 'ntfs', 0x1FE, "\x55\xAA", 0x3, "NTFS" ],
+ [ 'FAT32', 0x1FE, "\x55\xAA", 0x52, "FAT32" ],
+if_(arch() !~ /^sparc/,
+ [ 'FAT16', 0x1FE, "\x55\xAA", 0x36, "FAT" ],
+),
+);
+
+sub fs_type_from_magic {
+ my ($part) = @_;
+ if (exists $part->{fs_type_from_magic}) {
+ $part->{fs_type_from_magic};
+ } else {
+ my $type = type_subpart_from_magic($part);
+ $type && $type->{fs_type};
+ }
+}
+
+sub type_subpart_from_magic {
+ my ($part) = @_;
+ my $dev = devices::make($part->{device});
+ my $t = typeFromMagic($dev, @partitions_signatures) or return;
+
+ my $p = type_name2subpart($t) || fs_type2subpart($t) || internal_error("unknown name/fs $t");
+ if ($p->{fs_type} eq 'ext2') {
+ #- there is no magic to differentiate ext3 and ext2. Using libext2fs
+ #- to check if it has a journal
+ $p->{fs_type} = 'ext3' if c::is_ext3($dev);
+ }
+ $part->{fs_type_from_magic} = $p->{fs_type};
+ $p;
+}
+
+
+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 { $_[0]{fs_type} eq 'swap' }
+sub isDos { arch() !~ /^sparc/ && ${{ 1 => 1, 4 => 1, 6 => 1 }}{$_[0]{pt_type}} }
+sub isFat_or_NTFS { member($_[0]{fs_type}, 'vfat', 'ntfs') }
+sub isSunOS { arch() =~ /sparc/ && ${{ 0x1 => 1, 0x2 => 1, 0x4 => 1, 0x6 => 1, 0x7 => 1, 0x8 => 1 }}{$_[0]{pt_type}} }
+sub isApple { $_[0]{fs_type} eq 'apple' && defined $_[0]{isDriver} }
+sub isAppleBootstrap { $_[0]{fs_type} eq 'apple' && defined $_[0]{isBoot} }
+sub isHiddenMacPart { defined $_[0]{isMap} }
+
+sub isTrueFS { isTrueLocalFS($_[0]) || member($_[0]{fs_type}, qw(nfs)) }
+sub isTrueLocalFS { member($_[0]{fs_type}, qw(ext2 reiserfs xfs jfs ext3)) }
+
+sub isOtherAvailableFS { isEfi($_[0]) || isFat_or_NTFS($_[0]) || isSunOS($_[0]) || $_[0]{fs_type} eq 'hfs' } #- other OS that linux can access its filesystem
+sub isMountableRW { (isTrueFS($_[0]) || isOtherAvailableFS($_[0])) && $_[0]{fs_type} ne 'ntfs' }
+sub isNonMountable {
+ my ($part) = @_;
+ isRawRAID($part) || isRawLVM($part) || $part->{fs_type} eq 'ntfs' && !$part->{isFormatted} && $part->{notFormatted};
+}
+
+sub isPartOfLVM { defined $_[0]{lvm} }
+sub isPartOfRAID { defined $_[0]{raid} }
+sub isPartOfLoopback { defined $_[0]{loopback} }
+sub isRAID { $_[0]{device} =~ /^md/ }
+sub isUBD { $_[0]{device} =~ /^ubd/ } #- should be always true during an $::uml_install
+sub isLVM { $_[0]{VG_name} }
+sub isLoopback { defined $_[0]{loopback_file} }
+sub isMounted { $_[0]{isMounted} }
+sub isBusy { isMounted($_[0]) || isPartOfRAID($_[0]) || isPartOfLVM($_[0]) || isPartOfLoopback($_[0]) }
+sub isSpecial { isRAID($_[0]) || isLVM($_[0]) || isLoopback($_[0]) || isUBD($_[0]) }
+
+sub maybeFormatted {
+ my ($part) = @_;
+ $part->{isFormatted} || !$part->{notFormatted} && !$part->{bad_fs_type_magic};
+}
+sub set_isFormatted {
+ my ($part, $val) = @_;
+ $part->{isFormatted} = $val;
+ $part->{notFormatted} = !$val;
+ delete $part->{bad_fs_type_magic};
+ delete $part->{fs_type_from_magic};
+}
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index 0c5d8fe4b..c3bb56d6f 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -8,8 +8,9 @@ use vars qw(%suggestions);
#- misc imports
#-######################################################################################
use common;
-use partition_table qw(:types);
+use partition_table;
use partition_table::raw;
+use fs::type;
use detect_devices;
use fsedit;
use devices;
@@ -19,21 +20,21 @@ use fs;
%suggestions = (
N_("simple") => [
- { 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 },
+ { mntpoint => "/", size => 300 << 11, fs_type => 'ext3', ratio => 5, maxsize => 6000 << 11 },
+ { mntpoint => "swap", size => 64 << 11, fs_type => 'swap', ratio => 1, maxsize => 500 << 11 },
+ { mntpoint => "/home", size => 300 << 11, fs_type => 'ext3', ratio => 3 },
], N_("with /usr") => [
- { 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 },
+ { mntpoint => "/", size => 250 << 11, fs_type => 'ext3', ratio => 1, maxsize => 2000 << 11 },
+ { mntpoint => "swap", size => 64 << 11, fs_type => 'swap', ratio => 1, maxsize => 500 << 11 },
+ { mntpoint => "/usr", size => 300 << 11, fs_type => 'ext3', ratio => 4, maxsize => 4000 << 11 },
+ { mntpoint => "/home", size => 100 << 11, fs_type => 'ext3', ratio => 3 },
], N_("server") => [
- { 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 },
+ { mntpoint => "/", size => 150 << 11, fs_type => 'ext3', ratio => 1, maxsize => 800 << 11 },
+ { mntpoint => "swap", size => 64 << 11, fs_type => 'swap', ratio => 2, maxsize => 800 << 11 },
+ { mntpoint => "/usr", size => 300 << 11, fs_type => 'ext3', ratio => 4, maxsize => 4000 << 11 },
+ { mntpoint => "/var", size => 200 << 11, fs_type => 'ext3', ratio => 3 },
+ { mntpoint => "/home", size => 150 << 11, fs_type => 'ext3', ratio => 3 },
+ { mntpoint => "/tmp", size => 150 << 11, fs_type => 'ext3', ratio => 2, maxsize => 1000 << 11 },
],
);
foreach (values %suggestions) {
@@ -48,33 +49,6 @@ my @suggestions_mntpoints = (
#- RedHat also has /usr/local and /opt
);
-my @partitions_signatures = (
- [ 0x8e, 0, "HM\1\0" ],
- [ 0x83, 0x438, "\x53\xEF" ],
- [ 0x183, 0x10034, "ReIsErFs" ],
- [ 0x183, 0x10034, "ReIsEr2Fs" ],
- [ 0x283, 0, 'XFSB', 0x200, 'XAGF', 0x400, 'XAGI' ],
- [ 0x383, 0x8000, 'JFS1' ],
- [ 0x82, 4086, "SWAP-SPACE" ],
- [ 0x82, 4086, "SWAPSPACE2" ],
- [ 0x107, 0x1FE, "\x55\xAA", 0x3, "NTFS" ],
- [ 0xc, 0x1FE, "\x55\xAA", 0x52, "FAT32" ],
-if_(arch() !~ /^sparc/,
- [ 0x6, 0x1FE, "\x55\xAA", 0x36, "FAT" ],
-),
-);
-
-sub typeOfPart {
- my $dev = devices::make($_[0]);
- my $t = typeFromMagic($dev, @partitions_signatures);
- if ($t == 0x83) {
- #- there is no magic to differentiate ext3 and ext2. Using libext2fs
- #- to check if it has a journal
- $t = 0x483 if c::is_ext3($dev);
- }
- $t;
-}
-
#-######################################################################################
#- Functions
#-######################################################################################
@@ -113,10 +87,10 @@ sub raids {
my @raw_mdparts = map { /([^\[]+)/ } split ' ', $mdparts;
- 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 $fs_type = fs::type::fs_type_from_magic({ device => "md$nb" });
+ log::l("RAID: found md$nb (raid $level) chunks $chunks ", if_($fs_type, "type $fs_type "), "with parts ", join(", ", @raw_mdparts));
+ $raids[$nb] = { 'chunk-size' => $chunks, fs_type => $fs_type || 'ext2', raw_mdparts => \@raw_mdparts,
+ device => "md$nb", notFormatted => !$fs_type, level => $level };
}
my %devname2part = map { $_->{dev} => { %$_, device => $_->{dev} } } devices::read_proc_partitions_raw();
@@ -127,7 +101,7 @@ sub raids {
my $mdpart = $devname2part{$_} || { device => $_ };
if (my $part = find { is_same_hd($mdpart, $_) } @parts, @raids) {
$part->{raid} = $::i;
- $part->{pt_type} = 0xfd;
+ fs::type::set_pt_type($part, 0xfd);
delete $part->{mntpoint};
$part;
} else {
@@ -205,8 +179,9 @@ sub hds {
if ($hd->{readonly}) {
log::l("using /proc/partitions since diskdrake failed :(");
use_proc_partitions($hd);
- } elsif (exists $hd->{usb_description} && ($hd->{pt_type} ||= typeOfPart($hd->{device}))) {
+ } elsif (exists $hd->{usb_description} && fs::type::fs_type_from_magic($hd)) {
#- non partitioned drive
+ $hd->{fs_type} = fs::type::fs_type_from_magic($hd);
push @raw_hds, $hd;
next;
} elsif ($o_ask_before_blanking && $o_ask_before_blanking->($hd->{device}, $err)) {
@@ -223,19 +198,18 @@ sub hds {
my @parts = partition_table::get_normal_parts($hd);
- # special case for Various type
- $_->{pt_type} = typeOfPart($_->{device}) || 0x100 foreach grep { $_->{pt_type} == 0x100 } @parts;
-
- #- special case for type overloading (eg: reiserfs is 0x183)
- foreach (grep { isExt2($_) || $_->{pt_type} == 0x7 || $_->{pt_type} == 0x17 } @parts) {
- 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');
+ # checking the magic of the filesystem, don't rely on pt_type
+ foreach (grep { member($_->{fs_type}, 'vfat', 'ntfs', 'ext2') || $_->{pt_type} == 0x100 } @parts) {
+ if (my $fs_type = fs::type::fs_type_from_magic($_)) {
+ $_->{fs_type} = $fs_type;
+ } else {
+ $_->{bad_fs_type_magic} = 1;
+ }
}
foreach (@parts) {
my $label =
- member(type2fs($_), qw(ext2 ext3)) ?
+ member($_->{fs_type}, qw(ext2 ext3)) ?
c::get_ext2_label(devices::make($_->{device})) :
'';
$_->{device_LABEL} = $label if $label;
@@ -310,8 +284,8 @@ sub read_proc_partitions {
$part->{device} = $dev;
$part->{size} *= 2; # from KB to sectors
- $part->{pt_type} = typeOfPart($dev);
$part->{start} = $prev_part ? $prev_part->{start} + $prev_part->{size} : 0;
+ put_in_hash($part, fs::type::type_subpart_from_magic($part));
$prev_part = $part;
delete $part->{dev}; # cleanup
}
@@ -345,7 +319,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', 'pt_type', 'rootDevice') {
+ foreach ('start', 'size', 'pt_type', 'fs_type', 'rootDevice') {
$part1->{$_} eq $part2->{$_} or return;
}
1;
@@ -358,7 +332,7 @@ sub get_fstab {
#- get normal partition that should be visible for working on.
sub get_visible_fstab {
- grep { $_ && !partition_table::isWholedisk($_) && !partition_table::isHiddenMacPart($_) }
+ grep { $_ && !isWholedisk($_) && !isHiddenMacPart($_) }
map { partition_table::get_normal_parts($_) } @_;
}
@@ -482,6 +456,11 @@ sub suggest_part {
my ($part, $all_hds, $o_suggestions) = @_;
my $suggestions = $o_suggestions || $suggestions{server} || $suggestions{simple};
+ #- suggestions now use {fs_type}, but still keep compatibility
+ foreach (@$suggestions) {
+ fs::type::set_pt_type($_, $_->{pt_type}) if !exists $_->{fs_type};
+ }
+
my $has_swap = any { isSwap($_) } get_all_fstab($all_hds);
my @local_suggestions =
@@ -492,13 +471,13 @@ sub suggest_part {
my ($best) =
grep { !$_->{maxsize} || $part->{size} <= $_->{maxsize} }
grep { $_->{size} <= ($part->{maxsize} || $part->{size}) }
- grep { !$part->{pt_type} || $part->{pt_type} == $_->{pt_type} || isTrueFS($part) && isTrueFS($_) }
+ grep { !$part->{fs_type} || $part->{fs_type} eq $_->{fs_type} || isTrueFS($part) && isTrueFS($_) }
@local_suggestions;
defined $best or return; #- sorry no suggestion :(
$part->{mntpoint} = $best->{mntpoint};
- $part->{pt_type} = $best->{pt_type} if !(isTrueFS($best) && isTrueFS($part));
+ fs::type::set_type_subpart($part, $best) if !isTrueFS($best) || !isTrueFS($part);
$part->{size} = computeSize($part, $best, $all_hds, \@local_suggestions);
foreach ('options', 'lv_name', 'encrypt_key') {
$part->{$_} = $best->{$_} if $best->{$_};
@@ -526,11 +505,11 @@ sub get_root_ {
}
sub get_root { &get_root_ || {} }
-#- 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");
+#- do this before modifying $part->{fs_type}
+sub check_fs_type {
+ my ($fs_type, $_hd, $part) = @_;
+ $fs_type eq "jfs" && $part->{size} < 16 << 11 and die N("You can't use JFS for partitions smaller than 16MB");
+ $fs_type eq "reiserfs" && $part->{size} < 32 << 11 and die N("You can't use ReiserFS for partitions smaller than 32MB");
}
sub package_needed_for_partition_type {
@@ -540,7 +519,7 @@ sub package_needed_for_partition_type {
xfs => 'xfsprogs',
jfs => 'jfsprogs',
);
- $l{type2fs($part)};
+ $l{$part->{fs_type}};
}
#- you can do this before modifying $part->{mntpoint}
@@ -655,7 +634,7 @@ sub auto_allocate_raids {
my %h = %$md;
delete @h{'hd', 'parts'};
- put_in_hash($part, \%h); # mntpoint, level, chunk-size, pt_type
+ put_in_hash($part, \%h); # mntpoint, level, chunk-size, fs_type
raid::updateSize($part);
}
}
@@ -769,16 +748,15 @@ sub move {
}
}
-sub change_pt_type {
- my ($pt_type, $hd, $part) = @_;
- $pt_type != $part->{pt_type} or return;
- check_pt_type($pt_type, $hd, $part);
+sub change_type {
+ my ($type, $hd, $part) = @_;
+ $type->{pt_type} != $part->{pt_type} || $type->{fs_type} ne $part->{fs_type} or return;
+ check_fs_type($type->{fs_type}, $hd, $part);
$hd->{isDirty} = 1;
$part->{mntpoint} = '' if isSwap($part) && $part->{mntpoint} eq "swap";
- $part->{mntpoint} = '' if isRawLVM({ pt_type => $pt_type }) || isRawRAID({ pt_type => $pt_type });
- $part->{pt_type} = $pt_type;
- $part->{notFormatted} = 1;
- $part->{isFormatted} = 0;
+ $part->{mntpoint} = '' if isRawLVM($type) || isRawRAID($type);
+ set_isFormatted($part, 0);
+ fs::type::set_type_subpart($part, $type);
fs::rationalize_options($part);
1;
}
@@ -792,7 +770,8 @@ 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, pt_type => hex($id) };
+ my $part = { start => $st, size => $si };
+ fs::type::set_pt_type($part, hex($id));
if (isExtended($part)) {
$ext = $part;
} else {
diff --git a/perl-install/install2.pm b/perl-install/install2.pm
index 8d785cae7..0ffa83454 100644
--- a/perl-install/install2.pm
+++ b/perl-install/install2.pm
@@ -17,7 +17,7 @@ use keyboard;
use mouse;
use fsedit;
use devices;
-use partition_table qw(:types);
+use partition_table;
use modules;
use detect_devices;
use run_program;
diff --git a/perl-install/install_any.pm b/perl-install/install_any.pm
index 66511f2e1..fdfe55111 100644
--- a/perl-install/install_any.pm
+++ b/perl-install/install_any.pm
@@ -16,8 +16,8 @@ use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK $boot_medium $current_medium $asked_med
use MDK::Common::System;
use common;
use run_program;
-use partition_table qw(:types);
-use partition_table::raw;
+use fs::type;
+use partition_table;
use devices;
use fsedit;
use modules;
@@ -801,7 +801,7 @@ sub g_auto_install {
require pkgs;
$o->{default_packages} = pkgs::selected_leaves($::o->{packages});
- my @fields = qw(mntpoint pt_type size);
+ my @fields = qw(mntpoint fs_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
@@ -988,7 +988,9 @@ sub loadO {
#- handle backward compatibility for things that changed
foreach (@{$o->{partitions} || []}, @{$o->{manualFstab} || []}) {
- $_->{pt_type} ||= $_->{type};
+ if (my $pt_type = delete $_->{type}) {
+ fs::type::set_pt_type($_, $pt_type);
+ }
}
$o;
@@ -1118,7 +1120,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({ pt_type => fsedit::typeOfPart($_->{device}) }) } @{$o->{fstab}};
+ my @win = grep { isFat_or_NTFS($_) && maybeFormatted($_) } @{$o->{fstab}};
log::l("win parts: ", join ",", map { $_->{device} } @win) if @win;
if (@win == 1) {
#- Suggest /boot/efi on ia64.
@@ -1130,7 +1132,7 @@ sub getHds {
}
}
- my @sunos = grep { isSunOS($_) && part2name($_) =~ /root/i } @{$o->{fstab}}; #- take only into account root partitions.
+ my @sunos = grep { $_->{pt_type} == 2 } @{$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 e86c10bb6..79d768736 100644
--- a/perl-install/install_interactive.pm
+++ b/perl-install/install_interactive.pm
@@ -4,8 +4,9 @@ use diagnostics;
use strict;
use common;
-use partition_table qw(:types);
+use partition_table;
use partition_table::raw;
+use fs::type;
use detect_devices;
use install_steps;
use install_any;
@@ -107,7 +108,7 @@ sub partitionWizardSolutions {
push @wizlog, N("There is no existing partition to use");
}
- my @fats = grep { isFat($_) } @$fstab;
+ my @fats = grep { $_->{fs_type} eq 'vfat' } @$fstab;
fs::df($_) foreach @fats;
if (my @ok_forloopback = sort { $b->{free} <=> $a->{free} } grep { $_->{free} > $min_linux + $min_swap + $min_freewin } @fats) {
$solutions{loopback} =
@@ -121,8 +122,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}},
- { 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 };
+ { fs_type => 'ext3', loopback_file => '/lnx4win/linuxsys.img', mntpoint => '/', size => $s_root << 11, loopback_device => $part, notFormatted => 1 },
+ { fs_type => 'swap', loopback_file => '/lnx4win/swapfile', mntpoint => 'swap', size => $s_swap << 11, loopback_device => $part, notFormatted => 1 };
fsedit::recompute_loopbacks($all_hds);
1;
} ];
@@ -141,7 +142,7 @@ sub partitionWizardSolutions {
}, \&partition_table::description, \@ok_for_resize_fat) or return;
my $hd = fsedit::part2hd($part, $all_hds);
my $resize_fat = eval {
- my $pkg = isFat($part) ? do {
+ my $pkg = $part->{fs_type} eq 'vfat' ? do {
require resize_fat::main;
'resize_fat::main';
} : do {
@@ -192,9 +193,9 @@ When sure, press Ok."))) or return;
}
$o->ask_warn('', N("To ensure data integrity after resizing the partition(s),
-filesystem checks will be run on your next boot into Windows(TM)")) if !isFat($part);
+filesystem checks will be run on your next boot into Windows(TM)")) if $part->{fs_type} ne 'vfat';
- $part->{isFormatted} = 1;
+ set_isFormatted($part, 1);
partition_table::will_tell_kernel($hd, resize => $part); #- down-sizing, write_partitions is not needed
partition_table::adjust_local_extended($hd, $part);
partition_table::adjust_main_extended($hd);
diff --git a/perl-install/install_steps.pm b/perl-install/install_steps.pm
index 645f3fe0d..6cef62347 100644
--- a/perl-install/install_steps.pm
+++ b/perl-install/install_steps.pm
@@ -9,8 +9,9 @@ use vars qw(@filesToSaveForUpgrade @filesNewerToUseAfterUpgrade);
#-######################################################################################
use common;
use install_any qw(:all);
-use partition_table qw(:types);
+use partition_table;
use detect_devices;
+use fs::type;
use modules;
use run_program;
use lang;
@@ -215,7 +216,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}}, { pt_type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" };
+ push @{$o->{all_hds}{nfss}}, { fs_type => 'nfs', mntpoint => "/mnt/nfs", device => $1, options => "noauto,ro,nosuid,soft,rsize=8192,wsize=8192" };
}
#------------------------------------------------------------------------------
@@ -243,7 +244,7 @@ sub ask_mntpoint_s {#-}}}
$m{$m} = 1;
#- in case the type does not correspond, force it to ext3
- $_->{pt_type} = 0x483 if $m =~ m|^/| && !isTrueFS($_) && !isOtherAvailableFS($_);
+ fs::type::set_fs_type($_, 'ext3') if $m =~ m|^/| && !isTrueFS($_) && !isOtherAvailableFS($_);
}
1;
}
@@ -266,10 +267,8 @@ sub choosePartitionsToFormat($$) {
$_->{$::recovery ? 'toFormat' : 'toFormatUnsure'} ||= member($_->{mntpoint}, '/', '/usr');
if (!$_->{toFormat}) {
- 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({ pt_type => $t }) ? !isOtherAvailableFS($_) : $t != $_->{pt_type});
+ my $fs_type = fs::type::fs_type_from_magic($_);
+ $_->{toFormatUnsure} ||= !$fs_type || $fs_type ne $_->{fs_type};
}
}
}
diff --git a/perl-install/install_steps_interactive.pm b/perl-install/install_steps_interactive.pm
index 8be4fa5fe..6f0e0f68e 100644
--- a/perl-install/install_steps_interactive.pm
+++ b/perl-install/install_steps_interactive.pm
@@ -12,8 +12,8 @@ use vars qw(@ISA $new_bootstrap);
#- misc imports
#-######################################################################################
use common;
-use partition_table qw(:types);
-use partition_table::raw;
+use partition_table;
+use fs::type;
use install_steps;
use install_interactive;
use install_any;
@@ -286,7 +286,9 @@ 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, pt_type => 0x401, mntpoint => '' }, $o->{all_hds}, { force => 1, primaryOrExtended => 'Primary' });
+ my $p = { start => $freepart->{start}, size => 1 << 11, mntpoint => '' };
+ fs::type::set_pt_type($p, 0x401);
+ fsedit::add($freepart->{hd}, $p, $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"));
@@ -335,7 +337,7 @@ sub choosePartitionsToFormat {
({
text => partition_table::description($e), type => 'bool',
val => \$e->{toFormatTmp}
- }, if_(!isLoopback($_) && !isThisFs("reiserfs", $_) && !isThisFs("xfs", $_) && !isThisFs("jfs", $_), {
+ }, if_(!isLoopback($_) && !member($_->{fs_type}, 'reiserfs', 'xfs', 'jfs'), {
text => partition_table::description($e), type => 'bool', advanced => 1,
disabled => sub { !$e->{toFormatTmp} },
val => \$e->{toFormatCheck}
@@ -344,7 +346,7 @@ sub choosePartitionsToFormat {
#- ok now we can really set toFormat
foreach (@l) {
$_->{toFormat} = delete $_->{toFormatTmp};
- $_->{isFormatted} = 0;
+ set_isFormatted($_, 0);
}
}
@@ -1251,7 +1253,7 @@ sub miscellaneous {
require security::level;
security::level::level_choose($o, \$o->{security}, \$o->{libsafe}, \$o->{security_user});
- if ($o->{security} > 2 && find { isFat($_) } @{$o->{fstab}}) {
+ if ($o->{security} > 2 && find { $_->{fs_type} eq 'vfat' } @{$o->{fstab}}) {
$o->ask_okcancel('', N("In this security level, access to the files in the Windows partition is restricted to the administrator."))
or goto &miscellaneous;
}
diff --git a/perl-install/loopback.pm b/perl-install/loopback.pm
index 64dbe079e..bdb580a8b 100644
--- a/perl-install/loopback.pm
+++ b/perl-install/loopback.pm
@@ -8,7 +8,7 @@ use strict;
#-######################################################################################
use MDK::Common::System;
use common;
-use partition_table qw(:types);
+use fs::type;
use fs;
use fsedit;
use log;
diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm
index 2d2a6d0e7..e63daa1ff 100644
--- a/perl-install/lvm.pm
+++ b/perl-install/lvm.pm
@@ -10,6 +10,7 @@ use common;
use modules;
use fsedit;
use devices;
+use fs::type;
use run_program;
#- for partition_table_xxx emulation
@@ -92,10 +93,10 @@ sub get_lvs {
[
map {
my $device = "$lvm->{VG_name}/$_";
- my $pt_type = -e "/dev/$device" && fsedit::typeOfPart($device);
+ my $fs_type = -e "/dev/$device" && fs::type::fs_type_from_magic({ device => $device });
{ device => $device,
- pt_type => $pt_type || 0x83,
+ fs_type => $fs_type || 'ext2',
size => get_lv_size($device) }
} @l
];
@@ -117,8 +118,7 @@ sub vg_destroy {
lvm_cmd_or_die('vgremove', $lvm->{VG_name});
foreach (@{$lvm->{disks}}) {
delete $_->{lvm};
- $_->{isFormatted} = 0;
- $_->{notFormatted} = 1;
+ set_isFormatted($_, 0);
}
}
@@ -138,8 +138,7 @@ sub lv_create {
$lv->{device} = "$lvm->{VG_name}/$lv->{lv_name}";
lvm_cmd_or_die('lvcreate', '--size', int($lv->{size} / 2) . 'k', '-n', $lv->{lv_name}, $lvm->{VG_name});
$lv->{size} = get_lv_size($lv->{device}); #- the created size is smaller than asked size
- $lv->{notFormatted} = 1;
- $lv->{isFormatted} = 0;
+ set_isFormatted($lv, 0);
push @$list, $lv;
}
diff --git a/perl-install/network/smbnfs.pm b/perl-install/network/smbnfs.pm
index d9b53aedb..9e587a10f 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, $pt_type) = @_;
- my $fs_entry = { device => $class->to_dev($e), pt_type => $pt_type };
+ my ($class, $e, $fs_type) = @_;
+ my $fs_entry = { device => $class->to_dev($e), fs_type => $fs_type };
fs::set_default_options($fs_entry);
$fs_entry;
}
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index 812ed4826..e9bdfb4fc 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -2,272 +2,15 @@ package partition_table; # $Id$
use diagnostics;
use strict;
-use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @important_types @important_types2 @fields2save @bad_types);
-
-@ISA = qw(Exporter);
-%EXPORT_TAGS = (
- types => [ qw(part2name 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;
-
use common;
+use fs::type;
use partition_table::raw;
use detect_devices;
+use fs::type;
use log;
-@important_types = ('Linux native', 'Linux swap', 'Journalised FS: ext3', 'Journalised FS: ReiserFS',
- if_(arch() =~ /ppc/, 'Journalised FS: JFS', 'Journalised FS: XFS', 'Apple HFS Partition', 'Apple Bootstrap'),
- if_(arch() =~ /i.86/, 'Journalised FS: JFS', 'Journalised FS: XFS', 'FAT32'),
- if_(arch() =~ /ia64/, 'Journalised FS: XFS', 'FAT32'),
- if_(arch() =~ /x86_64/, 'FAT32'),
- );
-@important_types2 = ('Linux RAID', 'Linux Logical Volume Manager');
-
-@fields2save = qw(primary extended totalsectors isDirty will_tell_kernel);
-
-@bad_types = ('Empty', 'Extended', 'W95 Extended (LBA)', 'Linux extended');
-
-my %pt_type2name = (
- 0x0 => 'Empty',
-if_(arch() =~ /^ppc/,
- 0x183 => 'Journalised FS: ReiserFS',
- 0x283 => 'Journalised FS: XFS',
- 0x383 => 'Journalised FS: JFS',
- 0x483 => 'Journalised FS: ext3',
- 0x401 => 'Apple Partition',
- 0x401 => 'Apple Bootstrap',
- 0x402 => 'Apple HFS Partition',
-), if_(arch() =~ /^i.86/,
- 0x107 => 'NTFS',
- 0x183 => 'Journalised FS: ReiserFS',
- 0x283 => 'Journalised FS: XFS',
- 0x383 => 'Journalised FS: JFS',
- 0x483 => 'Journalised FS: ext3',
-), if_(arch() =~ /^ia64/,
- 0x100 => 'Various',
- 0x183 => 'Journalised FS: ReiserFS',
- 0x283 => 'Journalised FS: XFS',
- 0x483 => 'Journalised FS: ext3',
-), if_(arch() =~ /^x86_64/,
- 0x183 => 'Journalised FS: ReiserFS',
- 0x483 => 'Journalised FS: ext3',
-), if_(arch() =~ /^sparc/,
- 0x01 => 'SunOS boot',
- 0x02 => 'SunOS root',
- 0x03 => 'SunOS swap',
- 0x04 => 'SunOS usr',
- 0x05 => 'Whole disk',
- 0x06 => 'SunOS stand',
- 0x07 => 'SunOS var',
- 0x08 => 'SunOS home',
-), if_(arch() =~ /^i.86/,
- 0x01 => 'FAT12',
- 0x02 => 'XENIX root',
- 0x03 => 'XENIX usr',
- 0x04 => 'FAT16 <32M',
- 0x05 => 'Extended',
- 0x06 => 'FAT16',
- 0x07 => 'NTFS (or HPFS)',
- 0x08 => 'AIX',
-),
- 0x09 => 'AIX bootable',
- 0x0a => 'OS/2 Boot Manager',
- 0x0b => 'FAT32',
- 0x0c => 'W95 FAT32 (LBA)',
- 0x0e => 'W95 FAT16 (LBA)',
- 0x0f => 'W95 Extended (LBA)',
- 0x10 => 'OPUS',
- 0x11 => 'Hidden FAT12',
- 0x12 => 'Compaq diagnostics',
- 0x14 => 'Hidden FAT16 <32M',
- 0x16 => 'Hidden FAT16',
- 0x17 => 'Hidden HPFS/NTFS',
- 0x18 => 'AST SmartSleep',
- 0x1b => 'Hidden W95 FAT32',
-
- 0x1c => 'Hidden W95 FAT32 (LBA)',
- 0x1e => 'Hidden W95 FAT16 (LBA)',
- 0x24 => 'NEC DOS',
- 0x39 => 'Plan 9',
- 0x3c => 'PartitionMagic recovery',
- 0x40 => 'Venix 80286',
- 0x41 => 'PPC PReP Boot',
- 0x42 => 'SFS',
- 0x4d => 'QNX4.x',
- 0x4e => 'QNX4.x 2nd part',
- 0x4f => 'QNX4.x 3rd part',
-
- 0x50 => 'OnTrack DM',
- 0x51 => 'OnTrack DM6 Aux1',
- 0x52 => 'CP/M',
- 0x53 => 'OnTrack DM6 Aux3',
- 0x54 => 'OnTrackDM6',
- 0x55 => 'EZ-Drive',
- 0x56 => 'Golden Bow',
- 0x5c => 'Priam Edisk',
- 0x61 => 'SpeedStor',
- 0x63 => 'GNU HURD or SysV',
- 0x64 => 'Novell Netware 286',
- 0x65 => 'Novell Netware 386',
- 0x70 => 'DiskSecure Multi-Boot',
- 0x75 => 'PC/IX',
- 0x80 => 'Old Minix',
- 0x81 => 'Minix / old Linux',
-
-
- 0x82 => 'Linux swap',
- 0x83 => 'Linux native',
-
- 0x84 => 'OS/2 hidden C: drive',
- 0x85 => 'Linux extended',
- 0x86 => 'NTFS volume set',
- 0x87 => 'NTFS volume set',
- 0x8e => 'Linux Logical Volume Manager',
- 0x93 => 'Amoeba',
- 0x94 => 'Amoeba BBT',
- 0x9f => 'BSD/OS',
- 0xa0 => 'IBM Thinkpad hibernation',
- 0xa5 => 'FreeBSD',
- 0xa6 => 'OpenBSD',
- 0xa7 => 'NeXTSTEP',
- 0xa8 => 'Darwin UFS',
- 0xa9 => 'NetBSD',
- 0xab => 'Darwin boot',
- 0xb7 => 'BSDI fs',
- 0xb8 => 'BSDI swap',
- 0xbb => 'Boot Wizard hidden',
- 0xbe => 'Solaris boot',
- 0xc1 => 'DRDOS/sec (FAT-12)',
- 0xc4 => 'DRDOS/sec (FAT-16 < 32M)',
- 0xc6 => 'DRDOS/sec (FAT-16)',
- 0xc7 => 'Syrinx',
- 0xda => 'Non-FS data',
- 0xdb => 'CP/M / CTOS / ...',
- 0xde => 'Dell Utility',
- 0xdf => 'BootIt',
- 0xe1 => 'DOS access',
- 0xe3 => 'DOS R/O',
- 0xe4 => 'SpeedStor',
- 0xeb => 'BeOS fs',
- 0xee => 'EFI GPT',
- 0xef => 'EFI (FAT-12/16/32)',
- 0xf0 => 'Linux/PA-RISC boot',
- 0xf1 => 'SpeedStor',
- 0xf4 => 'SpeedStor',
- 0xf2 => 'DOS secondary',
- 0xfd => 'Linux RAID',
- 0xfe => 'LANstep',
- 0xff => 'BBT',
-);
-
-my %pt_type2fs = (
-arch() =~ /^ppc/ ? (
- 0x07 => 'hpfs',
-) : (
- 0x07 => 'ntfs',
-),
-arch() !~ /sparc/ ? (
- 0x01 => 'vfat',
- 0x04 => 'vfat',
- 0x05 => 'ignore',
- 0x06 => 'vfat',
-) : (
- 0x01 => 'ufs',
- 0x02 => 'ufs',
- 0x04 => 'ufs',
- 0x06 => 'ufs',
- 0x07 => 'ufs',
- 0x08 => 'ufs',
-),
- 0x0b => 'vfat',
- 0x0c => 'vfat',
- 0x0e => 'vfat',
- 0x1b => 'vfat',
- 0x1c => 'vfat',
- 0x1e => 'vfat',
- 0x82 => 'swap',
- 0x83 => 'ext2',
- 0xeb => 'befs',
- 0xef => 'vfat',
- 0x107 => 'ntfs',
- 0x183 => 'reiserfs',
- 0x283 => 'xfs',
- 0x383 => 'jfs',
- 0x483 => 'ext3',
- 0x401 => 'apple',
- 0x402 => 'hfs',
-);
-
-my %name2pt_type = reverse %pt_type2name;
-my %fs2pt_type = reverse %pt_type2fs;
-
- foreach (@important_types, @important_types2, @bad_types) {
- exists $name2pt_type{$_} or die "unknown $_\n";
- }
-
-
-1;
-
-sub important_types() {
- my @l = (@important_types, if_($::expert, @important_types2, sort values %pt_type2name));
- difference2(\@l, \@bad_types);
-}
-
-sub type2fs {
- my ($part, $o_default) = @_;
- my $pt_type = $part->{pt_type};
- $pt_type2fs{$pt_type} || $pt_type =~ /^(\d+)$/ && $o_default || $pt_type;
-}
-sub fs2pt_type { $fs2pt_type{$_[0]} || $_[0] }
-sub part2name {
- my ($part) = @_;
- $pt_type2name{$part->{pt_type}} || $part->{pt_type};
-}
-sub name2pt_type {
- local ($_) = @_;
- /0x(.*)/ ? hex $1 : $name2pt_type{$_} || $_;
-}
-#sub name2type { { pt_type => name2pt_type($_[0]) } }
-
-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]{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]{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} }
-
-sub isThisFs { type2fs($_[1]) eq $_[0] }
-sub isTrueFS { isTrueLocalFS($_[0]) || member(type2fs($_[0]), qw(nfs)) }
-sub isTrueLocalFS { member(type2fs($_[0]), qw(ext2 reiserfs xfs jfs ext3)) }
-
-sub isOtherAvailableFS { isEfi($_[0]) || isFat_or_NTFS($_[0]) || isSunOS($_[0]) || isThisFs('hfs', $_[0]) } #- other OS that linux can access its filesystem
-sub isMountableRW { (isTrueFS($_[0]) || isOtherAvailableFS($_[0])) && !isThisFs('ntfs', $_[0]) }
-sub isNonMountable {
- my ($part) = @_;
- isRawRAID($part) || isRawLVM($part) || isThisFs("ntfs", $part) && !$part->{isFormatted} && $part->{notFormatted};
-}
-
-sub isPartOfLVM { defined $_[0]{lvm} }
-sub isPartOfRAID { defined $_[0]{raid} }
-sub isPartOfLoopback { defined $_[0]{loopback} }
-sub isRAID { $_[0]{device} =~ /^md/ }
-sub isUBD { $_[0]{device} =~ /^ubd/ } #- should be always true during an $::uml_install
-sub isLVM { $_[0]{VG_name} }
-sub isLoopback { defined $_[0]{loopback_file} }
-sub isMounted { $_[0]{isMounted} }
-sub isBusy { isMounted($_[0]) || isPartOfRAID($_[0]) || isPartOfLVM($_[0]) || isPartOfLoopback($_[0]) }
-sub isSpecial { isRAID($_[0]) || isLVM($_[0]) || isLoopback($_[0]) || isUBD($_[0]) }
-sub maybeFormatted { $_[0]{isFormatted} || !$_[0]{notFormatted} }
+our @fields2save = qw(primary extended totalsectors isDirty will_tell_kernel);
#- works for both hard drives and partitions ;p
@@ -281,7 +24,7 @@ sub description {
formatXiB($hd->{totalsectors} || $hd->{size}, 512),
$hd->{info} && ", $hd->{info}",
$hd->{mntpoint} && ", " . $hd->{mntpoint},
- $hd->{pt_type} && ", " . part2name($hd);
+ $hd->{fs_type} && ", $hd->{fs_type}";
}
sub isPrimary {
@@ -388,14 +131,11 @@ sub assign_device_numbers {
#- first verify there's at least one primary dos partition, otherwise it
#- means it is a secondary disk and all will be false :(
#-
- #- 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($_) || $_->{pt_type} == 0x7 || $_->{pt_type} == 0x17 } @{$hd->{primary}{normal}};
+ my ($c, @others) = grep { isFat_or_NTFS($_) } @{$hd->{primary}{normal}};
$i = ord 'C';
$c->{device_windobe} = chr($i++) if $c;
- $_->{device_windobe} = chr($i++) foreach grep { isFat_or_NTFS($_) || $_->{pt_type} == 0x7 || $_->{pt_type} == 0x17 } map { $_->{normal} } @{$hd->{extended}};
+ $_->{device_windobe} = chr($i++) foreach grep { isFat_or_NTFS($_) } map { $_->{normal} } @{$hd->{extended}};
$_->{device_windobe} = chr($i++) foreach @others;
}
@@ -634,7 +374,7 @@ sub tell_kernel {
log::l("tell kernel force_reboot, rebootNeeded is now $hd->{rebootNeeded}.");
foreach (@magic_parts) {
- syscall_('mount', $_->{real_mntpoint}, type2fs($_), c::MS_MGC_VAL()) or log::l(N("mount failed: ") . $!);
+ syscall_('mount', $_->{real_mntpoint}, $_->{fs_type}, c::MS_MGC_VAL()) or log::l(N("mount failed: ") . $!);
}
}
}
@@ -792,8 +532,7 @@ sub add {
get_normal_parts($hd) >= ($hd->{device} =~ /^rd/ ? 7 : $hd->{device} =~ /^(sd|ida|cciss|ataraid)/ ? 15 : 63) and cdie "maximum number of partitions handled by linux reached";
- $part->{notFormatted} = 1;
- $part->{isFormatted} = 0;
+ set_isFormatted($part, 0);
$part->{rootDevice} = $hd->{device};
$part->{start} ||= 1 if arch() !~ /^sparc/; #- starting at sector 0 is not allowed
adjustStartAndEnd($hd, $part) unless $b_forceNoAdjust;
@@ -868,3 +607,5 @@ sub save {
eval { output($file, Data::Dumper->Dump([\@h], ['$h']), "\0") }
or die N("Error writing to file %s", $file);
}
+
+1;
diff --git a/perl-install/partition_table/bsd.pm b/perl-install/partition_table/bsd.pm
index cdf18e6d1..0e2421c25 100644
--- a/perl-install/partition_table/bsd.pm
+++ b/perl-install/partition_table/bsd.pm
@@ -73,7 +73,7 @@ sub read($$) {
my $size = psizeof($format);
my @pt = map {
my %h; @h{@fields} = unpack $format, $_;
- $h{pt_type} = $pt_typeToDos{$h{pt_type}} || $h{pt_type};
+ fs::type::set_pt_type(\%h, $pt_typeToDos{$h{pt_type}} || $h{pt_type});
\%h;
} $info{partitions} =~ /(.{$size})/g;
diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm
index 38cdf60ed..8c30e6558 100644
--- a/perl-install/partition_table/dos.pm
+++ b/perl-install/partition_table/dos.pm
@@ -185,7 +185,9 @@ sub read {
my @pt = map {
sysread $F, $tmp, psizeof($format) or die "error while reading partition table in sector $sector";
- my %h; @h{@fields} = unpack $format, $tmp;
+ my %h;
+ @h{@fields} = unpack $format, $tmp;
+ fs::type::set_pt_type(\%h, $h{pt_type});
\%h;
} (1..$nb_primary);
diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm
index 2f1506bbd..423d73a7a 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{pt_type} = $gpt_types_rev{$h{gpt_type}};
- $h{pt_type} = 0x100 if !defined $h{pt_type};
+ my $pt_type = $gpt_types_rev{$h{gpt_type}};
+ fs::type::set_pt_type(\%h, defined $pt_type ? $pt_type : 0x100);
\%h;
} (1 .. $info->{nbPartitions});
\@pt;
diff --git a/perl-install/partition_table/mac.pm b/perl-install/partition_table/mac.pm
index 219b6434d..4b60710bb 100644
--- a/perl-install/partition_table/mac.pm
+++ b/perl-install/partition_table/mac.pm
@@ -7,6 +7,7 @@ use vars qw(@ISA $freepart $bootstrap_part $macos_part);
@ISA = qw(partition_table::raw);
use common;
+use fs::type;
use partition_table::raw;
use partition_table;
use c;
@@ -139,7 +140,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 +152,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 {
@@ -297,27 +298,27 @@ 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 ($_->{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;
diff --git a/perl-install/partition_table/sun.pm b/perl-install/partition_table/sun.pm
index 7c8a6beb9..54e734ca8 100644
--- a/perl-install/partition_table/sun.pm
+++ b/perl-install/partition_table/sun.pm
@@ -9,6 +9,7 @@ use vars qw(@ISA);
use common;
use partition_table::raw;
use partition_table;
+use fs::type;
use c;
my ($main_format, $main_fields) = list2kv(
@@ -92,8 +93,9 @@ 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 = { pt_type => $infos_up[2 * $_], flag => $infos_up[1 + 2 * $_],
+ my $h = { flag => $infos_up[1 + 2 * $_],
start_cylinder => $partitions_up[2 * $_], size => $partitions_up[1 + 2 * $_] };
+ fs::type::set_pt_type($h, $infos_up[2 * $_]);
$h->{start} = $sector + $h->{start_cylinder} * $hd->cylinder_size;
$h->{pt_type} && $h->{size} or $h->{$_} = 0 foreach keys %$h;
push @pt, $h;
@@ -133,7 +135,7 @@ sub write($$$;$) {
# $csize += $_->{size} if $_->{pt_type} != 5;
# $wdsize += $_->{size} if $_->{pt_type} == 5;
$_->{flags} |= 0x10 if $_->{mntpoint} eq '/';
- $_->{flags} |= 0x01 if partition_table::isSwap($_);
+ $_->{flags} |= 0x01 if !isSwap($_);
local $_->{start_cylinder} = $_->{start} / $hd->cylinder_size - $sector;
pack($format1, @$_{@$fields1}), pack($format2, @$_{@$fields2});
} @$pt;
diff --git a/perl-install/raid.pm b/perl-install/raid.pm
index 8b03e3375..d91f3984b 100644
--- a/perl-install/raid.pm
+++ b/perl-install/raid.pm
@@ -7,7 +7,7 @@ use strict;
#- misc imports
#-######################################################################################
use common;
-use partition_table qw(:types);
+use fs::type;
use run_program;
use devices;
use modules;
@@ -23,7 +23,7 @@ sub nb {
sub new {
my ($raids, @parts) = @_;
my $nb = @$raids;
- $raids->[$nb] = { 'chunk-size' => "64k", pt_type => 0x483, disks => [ @parts ], device => "md$nb", notFormatted => 1, level => 1 };
+ $raids->[$nb] = { 'chunk-size' => "64k", fs_type => 'ext3', disks => [ @parts ], device => "md$nb", notFormatted => 1, level => 1 };
foreach my $part (@parts) {
$part->{raid} = $nb;
delete $part->{mntpoint};
@@ -36,7 +36,7 @@ sub add {
my ($raids, $part, $nb) = @_; $nb = nb($nb);
$raids->[$nb]{isMounted} and die N("Can't add a partition to _formatted_ RAID md%d", $nb);
inactivate_and_dirty($raids->[$nb]);
- $part->{notFormatted} = 1; $part->{isFormatted} = 0;
+ set_isFormatted($part, 0);
$part->{raid} = $nb;
delete $part->{mntpoint};
push @{$raids->[$nb]{disks}}, $part;
@@ -145,7 +145,7 @@ sub format_part {
make($raids, $part);
fs::format::part_raw($part);
- $_->{isFormatted} = 1 foreach @{$part->{disks}};
+ set_isFormatted($_, 1) foreach @{$part->{disks}};
}
sub verify {
@@ -171,7 +171,7 @@ sub prepare_prefixed {
sub inactivate_and_dirty {
my ($part) = @_;
run_program::run("raidstop", devices::make($part->{device}));
- $part->{notFormatted} = 1; $part->{isFormatted} = 0;
+ set_isFormatted($part, 0);
}
sub active_mds() {