summaryrefslogtreecommitdiffstats
path: root/perl-install/diskdrake/interactive.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/diskdrake/interactive.pm')
-rw-r--r--perl-install/diskdrake/interactive.pm203
1 files changed, 101 insertions, 102 deletions
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index 269ff5aa5..412258eed 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;
@@ -14,7 +15,6 @@ use fsedit;
use raid;
use any;
use log;
-use fs;
=begin
@@ -25,7 +25,9 @@ struct part {
int active # one of { 0 | 0x80 } x86 only, primary only
int start # in sectors
int size # in sectors
- int pt_type # 0x82, 0x83, 0x6 ...
+ int pt_type # 0x82, 0x83, 0x6 ...
+ string fs_type # 'ext2', 'nfs', ...
+ int part_number # 1 for hda1...
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
@@ -40,6 +42,7 @@ struct part {
string comment # comment to have in fstab
string volume_label #
+ bool is_removable # is the partition on a removable drive
bool isMounted
bool isFormatted
@@ -48,7 +51,7 @@ struct part {
# !isFormatted && notFormatted means the device is not formatted
# !isFormatted && !notFormatted means we don't know which state we're in
- int raid # for partitions of type isRawRAID and which isPartOfRAID, the raid device number
+ string raid # for partitions of type isRawRAID and which isPartOfRAID, the raid device
string lvm # partition used as a PV for the VG with {lvm} as VG_name #-#
loopback loopback[] # loopback living on this partition
@@ -67,7 +70,7 @@ struct part_allocate inherits part {
}
struct part_raid inherits part {
- string chunk-size # usually '64k'
+ string chunk-size # in KiB, usually '64'
string level # one of { 0, 1, 4, 5, 'linear' }
part disks[]
@@ -144,7 +147,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'
@@ -154,7 +157,7 @@ struct raw_hd inherits hd {
struct all_hds {
hd hds[]
hd_lvm lvms[]
- part_raid raids[] # indexed by number: raids[$n]{device} is "md$n"
+ part_raid raids[]
part_loopback loopbacks[]
raw_hd raw_hds[]
raw_hd nfss[]
@@ -182,14 +185,14 @@ sub main {
while (1) {
my $choose_txt = $current_part ? N_("Choose another partition") : N_("Choose a partition");
- my $parts_and_holes = [ fsedit::get_all_fstab_and_holes($all_hds) ];
+ my $parts_and_holes = [ fs::get::fstab_and_holes($all_hds) ];
my $choose_part = sub {
$current_part = $in->ask_from_listf('diskdrake', translate($choose_txt),
sub {
- my $hd = fsedit::part2hd($_[0] || return, $all_hds);
+ my $hd = fs::get::part2hd($_[0] || return, $all_hds);
format_part_info_short($hd, $_[0]);
}, $parts_and_holes, $current_part) || return;
- $current_hd = fsedit::part2hd($current_part, $all_hds);
+ $current_hd = fs::get::part2hd($current_part, $all_hds);
};
$choose_part->() if !$current_part;
@@ -226,7 +229,7 @@ sub main {
} else {
$choose_part->();
}
- partition_table::assign_device_numbers($_) foreach fsedit::all_hds($all_hds);
+ partition_table::assign_device_numbers($_) foreach fs::get::hds($all_hds);
}
return if eval { Done($in, $all_hds) };
if (my $err = $@) {
@@ -406,14 +409,14 @@ sub Hd_info {
################################################################################
sub part_possible_actions {
- my ($_in, $hd, $part, $_all_hds) = @_;
+ my ($_in, $hd, $part, $all_hds) = @_;
$part or return;
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)',
@@ -423,14 +426,16 @@ sub part_possible_actions {
N_("Delete") => '!isBusy && !readonly',
N_("Remove from RAID") => 'isPartOfRAID',
N_("Remove from LVM") => 'isPartOfLVM',
- N_("Modify RAID") => 'isPartOfRAID && !isMounted($all_hds->{raids}[$part->{raid}])',
+ N_("Modify RAID") => 'canModifyRAID',
N_("Use for loopback") => '!$part->{real_mntpoint} && isMountableRW && !isSpecial && hasMntpoint && $::expert',
);
my ($actions_names) = list2kv(@l);
+ my $_all_hds = $all_hds; #- help perl_checker know the $all_hds *is* used in the macro below
my %macros = (
readonly => '$hd->{readonly}',
hasMntpoint => '$part->{mntpoint}',
isPrimary => 'isPrimary($part, $hd)',
+ canModifyRAID => 'isPartOfRAID($part) && !isMounted(fs::get::device2part($part->{raid}, $all_hds->{raids}))',
);
if ($part->{pt_type} eq '0') {
if_(!$hd->{readonly}, N_("Create"));
@@ -453,14 +458,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 = pt_type2name($part->{pt_type});
+ 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 +475,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,10 +497,10 @@ 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);
+ fs::mount_options::set_default($part, ignore_is_removable => 1);
check($in, $hd, $part, $all_hds) or return 1;
$migrate_files = need_migration($in, $part->{mntpoint}) or return 1;
@@ -559,38 +564,39 @@ 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 = pt_type2name($part->{pt_type});
+ 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::disable_forced_fsck($part->{device});
+ fs::format::disable_forced_fsck($part->{device});
return;
}
}
#- 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);
}
}
@@ -601,7 +607,7 @@ sub Mount_point {
my $mntpoint = $part->{mntpoint} || do {
my $part_ = { %$part };
if (fsedit::suggest_part($part_, $all_hds)) {
- fsedit::has_mntpoint('/', $all_hds) || $part_->{mntpoint} eq '/boot' ? $part_->{mntpoint} : '/';
+ fs::get::has_mntpoint('/', $all_hds) || $part_->{mntpoint} eq '/boot' ? $part_->{mntpoint} : '/';
} else { '' }
};
$in->ask_from_({ messages =>
@@ -657,7 +663,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 +672,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 +684,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;
}
@@ -726,11 +732,10 @@ sub Resize {
my $adjust = sub {
my ($write_partitions) = @_;
- partition_table::will_tell_kernel($hd, resize => $part);
-
if (isLVM($hd)) {
lvm::lv_resize($part, $oldsize);
} else {
+ partition_table::will_tell_kernel($hd, resize => $part);
partition_table::adjust_local_extended($hd, $part);
partition_table::adjust_main_extended($hd);
write_partitions($in, $hd) or return if $write_partitions && %nice_resize;
@@ -764,10 +769,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
}
@@ -803,17 +807,16 @@ sub Add2RAID {
my ($in, $_hd, $part, $all_hds) = @_;
my $raids = $all_hds->{raids};
- local $_ = @$raids == () ? "new" :
- $in->ask_from_list_('', N("Choose an existing RAID to add to"),
- [ (grep { $_ } map_index { $_ && "md$::i" } @$raids), N_("new") ]) or return;
+ my $md_part = $in->ask_from_listf('', N("Choose an existing RAID to add to"),
+ sub { ref($_[0]) ? $_[0]{device} : $_[0] },
+ [ @$raids, N_("new") ]) or return;
- if (/new/) {
- my $nb1 = raid::new($raids, $part);
- defined modifyRAID($in, $raids, $nb1) or return raid::delete($raids, $nb1);
+ if (ref($md_part)) {
+ raid::add($md_part, $part);
} else {
- raid::add($raids, $part, $_);
+ my $md_part = raid::new($raids, disks => [ $part ]);
+ modifyRAID($in, $raids, $md_part) or return raid::delete($raids, $md_part);
}
- raid::update(@$raids);
}
sub Add2LVM {
my ($in, $hd, $part, $all_hds) = @_;
@@ -856,7 +859,7 @@ sub RemoveFromLVM {
}
sub ModifyRAID {
my ($in, $_hd, $part, $all_hds) = @_;
- modifyRAID($in, $all_hds->{raids}, $part->{raid});
+ modifyRAID($in, $all_hds->{raids}, fs::get::device2part($part->{raid}, $all_hds->{raids}));
}
sub Loopback {
my ($in, $hd, $real_part, $all_hds) = @_;
@@ -866,20 +869,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 = pt_type2name($part->{pt_type});
+ 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 +897,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);
}
@@ -904,9 +907,9 @@ sub Options {
my @simple_options = qw(user noauto supermount username= password=);
- my (undef, $user_implies) = fs::mount_options();
- my ($options, $unknown) = fs::mount_options_unpack($part);
- my %help = fs::mount_options_help();
+ my (undef, $user_implies) = fs::mount_options::list();
+ my ($options, $unknown) = fs::mount_options::unpack($part);
+ my %help = fs::mount_options::help();
my $prev_user = $options->{user};
$in->ask_from(N("Mount options"),
@@ -926,7 +929,7 @@ sub Options {
if ($options->{encrypted}) {
# modify $part->{options} for the check
local $part->{options};
- fs::mount_options_pack($part, $options, $unknown);
+ fs::mount_options::pack($part, $options, $unknown);
if (!check($in, $hd, $part, $all_hds)) {
$options->{encrypted} = 0;
} elsif (!$part->{encrypt_key} && !isSwap($part)) {
@@ -944,7 +947,7 @@ sub Options {
},
) or return;
- fs::mount_options_pack($part, $options, $unknown);
+ fs::mount_options::pack($part, $options, $unknown);
1;
}
@@ -972,21 +975,23 @@ sub Options {
sub is_part_existing {
my ($part, $all_hds) = @_;
- $part && any { fsedit::are_same_partitions($part, $_) } fsedit::get_all_fstab_and_holes($all_hds);
+ $part && any { fsedit::are_same_partitions($part, $_) } fs::get::fstab_and_holes($all_hds);
}
sub modifyRAID {
- my ($in, $raids, $nb) = @_;
- my $md = "md$nb";
+ my ($in, $raids, $md_part) = @_;
+ my @free_mds = difference2([ map { "md$_" } 0 .. raid::max_nb() ], [ map { $_->{device} } @$raids ]);
+ my $prev_device = $md_part->{device};
$in->ask_from('', '',
[
-{ label => N("device"), val => \$md, list => [ map { "md$_" } grep { $nb == $_ || !$raids->[$_] } 0..8 ] },
-{ label => N("level"), val => \$raids->[$nb]{level}, list => [ qw(0 1 4 5 linear) ] },
-{ label => N("chunk size"), val => \$raids->[$nb]{'chunk-size'} },
+{ label => N("device"), val => \$md_part->{device}, list => [ $md_part->{device}, @free_mds ] },
+{ label => N("level"), val => \$md_part->{level}, list => [ qw(0 1 4 5 linear) ] },
+{ label => N("chunk size in KiB"), val => \$md_part->{'chunk-size'} },
],
) or return;
- raid::updateSize($raids->[$nb]); # changing the raid level changes the size available
- raid::changeNb($raids, $nb, first($md =~ /(\d+)/));
+ raid::change_device($md_part, $prev_device);
+ raid::updateSize($md_part); # changing the raid level changes the size available
+ 1;
}
@@ -1018,22 +1023,15 @@ 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 { fs::type::check($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") {
- $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;
- }
+ if ($::isStandalone && $type->{fs_type}) {
+ fs::format::check_package_is_installed($in->do_pkgs, $type->{fs_type}) or return;
}
1;
}
@@ -1052,7 +1050,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);
}
@@ -1081,9 +1079,12 @@ sub format_ {
my ($in, $hd, $part, $all_hds) = @_;
write_partitions($in, $_) or return foreach isRAID($part) ? @{$all_hds->{hds}} : $hd;
ask_alldatawillbelost($in, $part, N_("After formatting partition %s, all data on this partition will be lost")) or return;
+ if ($::isStandalone) {
+ fs::format::check_package_is_installed($in->do_pkgs, $part->{fs_type}) or return;
+ }
$part->{isFormatted} = 0; #- force format;
my $w;
- fs::format_part($all_hds->{raids}, $part, $::prefix, sub {
+ fs::format::part($all_hds->{raids}, $part, $::prefix, sub {
my ($msg) = @_;
$w ||= $in->wait_message('', $msg);
$w->set($msg);
@@ -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";
- }
- } 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";
+ 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->{fs_type} || $part->{pt_type}) {
+ $info .= N("Type: ") . (fs::type::part2type_name($part) || $part->{fs_type}) . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n";
} else {
$info .= N("Empty") . "\n";
}
@@ -1181,13 +1181,13 @@ sub format_part_info {
$info .= N("Formatted\n") if $part->{isFormatted};
$info .= N("Not formatted\n") if !$part->{isFormatted} && $part->{notFormatted};
$info .= N("Mounted\n") if $part->{isMounted};
- $info .= N("RAID md%s\n", $part->{raid}) if isPartOfRAID($part);
+ $info .= N("RAID %s\n", $part->{raid}) if isPartOfRAID($part);
$info .= sprintf "LVM %s\n", $part->{lvm} if isPartOfLVM($part);
$info .= N("Loopback file(s):\n %s\n", join(", ", map { $_->{loopback_file} } @{$part->{loopback}})) if isPartOfLoopback($part);
$info .= N("Partition booted by default\n (for MS-DOS boot, not for lilo)\n") if $part->{active} && $::expert;
if (isRAID($part)) {
$info .= N("Level %s\n", $part->{level});
- $info .= N("Chunk size %s\n", $part->{'chunk-size'});
+ $info .= N("Chunk size %d KiB\n", $part->{'chunk-size'});
$info .= N("RAID-disks %s\n", join ", ", map { $_->{device} } @{$part->{disks}});
} elsif (isLoopback($part)) {
$info .= N("Loopback file name: %s", $part->{loopback_file});
@@ -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(pt_type2name($raw_hd->{pt_type}), 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;
@@ -1297,5 +1296,5 @@ sub update_bootloader_for_renumbered_partitions {
my @renumbering = map { @{$_->{allPartitionsRenumbered} || []} } @{$all_hds->{hds}} or return;
require bootloader;
- bootloader::update_for_renumbered_partitions($in, \@renumbering, $all_hds->{hds});
+ bootloader::update_for_renumbered_partitions($in, \@renumbering, $all_hds);
}