summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/diskdrake/hd_gtk.pm12
-rw-r--r--perl-install/diskdrake/interactive.pm16
-rw-r--r--perl-install/fs/get.pm4
-rw-r--r--perl-install/fs/type.pm3
-rw-r--r--perl-install/partition_table.pm6
5 files changed, 20 insertions, 21 deletions
diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm
index 9de1dde04..d674d1e35 100644
--- a/perl-install/diskdrake/hd_gtk.pm
+++ b/perl-install/diskdrake/hd_gtk.pm
@@ -357,15 +357,15 @@ sub createOrChangeType {
{ pt_type => 0, start => 1, size => $hd->{totalsectors} - 1 };
$part or return;
if ($fs_type eq 'other') {
- $in->ask_warn('', N("Use ``%s'' instead", $part->{pt_type} ? N("Type") : N("Create")));
+ $in->ask_warn('', N("Use ``%s'' instead", isEmpty($part) ? N("Create") : N("Type")));
} elsif (!$fs_type) {
- $in->ask_warn('', N("Use ``%s'' instead", N("Delete"))) if $part->{pt_type};
- } elsif ($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 {
+ $in->ask_warn('', N("Use ``%s'' instead", N("Delete"))) if !isEmpty($part);
+ } elsif (isEmpty($part)) {
fs::type::set_fs_type($part, $fs_type);
diskdrake::interactive::Create($in, $hd, $part, $all_hds);
+ } else {
+ return if $fs_type eq $part->{fs_type};
+ $in->ask_warn('', isBusy($part) ? N("Use ``Unmount'' first") : N("Use ``%s'' instead", N("Type")));
}
}
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index 7c6c4c3fa..d06313b51 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -443,7 +443,7 @@ sub part_possible_actions {
isPrimary => 'isPrimary($part, $hd)',
canModifyRAID => 'isPartOfRAID($part) && !isMounted(fs::get::device2part($part->{raid}, $all_hds->{raids}))',
);
- if ($part->{pt_type} eq '0') {
+ if (isEmpty($part)) {
if_(!$hd->{readonly}, N_("Create"));
} else {
grep {
@@ -1173,17 +1173,17 @@ sub format_part_info {
$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 {
+ } elsif (isEmpty($part)) {
$info .= N("Empty") . "\n";
+ } else {
+ $info .= N("Type: ") . (fs::type::part2type_name($part) || $part->{fs_type}) . ($::expert ? sprintf " (0x%x)", $part->{pt_type} : '') . "\n";
}
$info .= N("Start: sector %s\n", $part->{start}) if $::expert && !isSpecial($part) && !isLVM($hd);
$info .= N("Size: %s", formatXiB($part->{size}, 512));
$info .= sprintf " (%s%%)", int 100 * $part->{size} / $hd->{totalsectors} if $hd->{totalsectors};
$info .= N(", %s sectors", $part->{size}) if $::expert;
$info .= "\n";
- $info .= N("Cylinder %d to %d\n", $part->{start} / $hd->cylinder_size, ($part->{start} + $part->{size} - 1) / $hd->cylinder_size) if ($::expert || !$part->{pt_type}) && !isSpecial($part) && !isLVM($hd);
+ $info .= N("Cylinder %d to %d\n", $part->{start} / $hd->cylinder_size, ($part->{start} + $part->{size} - 1) / $hd->cylinder_size) if ($::expert || isEmpty($part)) && !isSpecial($part) && !isLVM($hd);
$info .= N("Number of logical extents: %d", $part->{size} / $hd->cylinder_size) if $::expert && isLVM($hd);
$info .= N("Formatted\n") if $part->{isFormatted};
$info .= N("Not formatted\n") if !$part->{isFormatted} && $part->{notFormatted};
@@ -1212,9 +1212,7 @@ sub format_part_info {
sub format_part_info_short {
my ($hd, $part) = @_;
- $part->{pt_type} ?
- partition_table::description($part) :
- format_part_info($hd, $part);
+ isEmpty($part) ? format_part_info($hd, $part) : partition_table::description($part);
}
sub format_hd_info {
@@ -1238,7 +1236,7 @@ sub format_raw_hd_info {
my $info = '';
$info .= N("Mount point: ") . "$raw_hd->{mntpoint}\n" if $raw_hd->{mntpoint};
$info .= format_hd_info($raw_hd);
- if ($raw_hd->{pt_type}) {
+ if (!isEmpty($raw_hd)) {
$info .= N("Type: ") . (fs::type::part2type_name($raw_hd) || $raw_hd->{fs_type}) . "\n";
}
if (my $s = $raw_hd->{options}) {
diff --git a/perl-install/fs/get.pm b/perl-install/fs/get.pm
index 859ddf0ac..6b982c1e9 100644
--- a/perl-install/fs/get.pm
+++ b/perl-install/fs/get.pm
@@ -30,10 +30,10 @@ sub fstab_and_holes {
sub holes {
my ($all_hds) = @_;
- grep { $_->{pt_type} == 0 } fstab_and_holes($all_hds);
+ grep { isEmpty($_) } fstab_and_holes($all_hds);
}
sub hds_holes {
- grep { $_->{pt_type} == 0 } hds_fstab_and_holes(@_);
+ grep { isEmpty($_) } hds_fstab_and_holes(@_);
}
sub free_space {
my ($all_hds) = @_;
diff --git a/perl-install/fs/type.pm b/perl-install/fs/type.pm
index f9ff8f618..bca5d8f5a 100644
--- a/perl-install/fs/type.pm
+++ b/perl-install/fs/type.pm
@@ -8,7 +8,7 @@ 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
+ isEmpty 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
);
@@ -307,6 +307,7 @@ sub type_subpart_from_magic {
}
+sub isEmpty { !$_[0]{fs_type} && $_[0]{pt_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) }
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index 1d5e87e47..88bbcfd74 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -227,7 +227,7 @@ sub get_normal_parts_and_holes {
} sort { $a->{start} <=> $b->{start} } grep { !isWholedisk($_) } get_normal_parts($hd);
push @l, { start => $start, size => $last - $start, %$minimal_hole };
- grep { $_->{pt_type} || $_->{size} >= $hd->cylinder_size } @l;
+ grep { !isEmpty($_) || $_->{size} >= $hd->cylinder_size } @l;
}
sub read_one($$) {
@@ -264,8 +264,8 @@ sub read_one($$) {
}
my @extended = $hd->hasExtended ? grep { isExtended($_) } @$pt : ();
- my @normal = grep { $_->{size} && $_->{pt_type} && !isExtended($_) } @$pt;
- my $nb_special_empty = int(grep { $_->{size} && $_->{pt_type} == 0 } @$pt);
+ my @normal = grep { $_->{size} && !isEmpty($_) && !isExtended($_) } @$pt;
+ my $nb_special_empty = int(grep { $_->{size} && isEmpty($_) } @$pt);
@extended > 1 and die "more than one extended partition";