summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2011-02-14 12:51:17 +0000
committerAntoine Ginies <aginies@mandriva.com>2011-02-14 12:51:17 +0000
commit78840527a343272e3ed3bb7fce46d70b5e5b2ce9 (patch)
tree8a4727ce488d91572dce0a5bc472fe5b28ccd973
parent2cc14c2ae861f1ed514c2fbced7d4aac77de581b (diff)
downloaddrakx-backup-do-not-use-78840527a343272e3ed3bb7fce46d70b5e5b2ce9.tar
drakx-backup-do-not-use-78840527a343272e3ed3bb7fce46d70b5e5b2ce9.tar.gz
drakx-backup-do-not-use-78840527a343272e3ed3bb7fce46d70b5e5b2ce9.tar.bz2
drakx-backup-do-not-use-78840527a343272e3ed3bb7fce46d70b5e5b2ce9.tar.xz
drakx-backup-do-not-use-78840527a343272e3ed3bb7fce46d70b5e5b2ce9.zip
backport diskdrake from 2010.1, remove ext4 support
-rw-r--r--perl-install/diskdrake/dav.pm21
-rw-r--r--perl-install/diskdrake/hd_gtk.pm50
-rw-r--r--perl-install/diskdrake/interactive.pm371
-rw-r--r--perl-install/fs/any.pm9
-rw-r--r--perl-install/fs/dmcrypt.pm14
-rw-r--r--perl-install/fs/dmraid.pm18
-rw-r--r--perl-install/fs/format.pm143
-rw-r--r--perl-install/fs/mount.pm14
-rw-r--r--perl-install/fs/mount_options.pm24
-rw-r--r--perl-install/fs/mount_point.pm14
-rw-r--r--perl-install/fs/partitioning_wizard.pm543
-rw-r--r--perl-install/fs/type.pm37
-rw-r--r--perl-install/fs/wild_device.pm4
13 files changed, 909 insertions, 353 deletions
diff --git a/perl-install/diskdrake/dav.pm b/perl-install/diskdrake/dav.pm
index a358c987a..d236ba0f9 100644
--- a/perl-install/diskdrake/dav.pm
+++ b/perl-install/diskdrake/dav.pm
@@ -1,4 +1,4 @@
-package diskdrake::dav; # $Id: dav.pm 215411 2007-04-25 12:26:16Z pixel $
+package diskdrake::dav; # $Id: dav.pm 259328 2009-08-17 12:57:51Z alefebvre $
use diagnostics;
use strict;
@@ -37,6 +37,7 @@ sub create {
ask_server($in, $dav, $all_hds) or return;
push @{$all_hds->{davs}}, $dav;
config($in, $dav, $all_hds);
+ return;
}
sub config {
@@ -45,11 +46,12 @@ sub config {
my $dav = { %$dav_ }; #- working on a local copy so that "Cancel" works
my $action;
- while ($action ne 'Done') {
+ my $exit;
+ while (!$exit && $action ne 'Done') {
my %actions = my @actions = actions($dav);
$action = $in->ask_from_list_('', format_dav_info($dav),
[ map { $_->[0] } group_by2 @actions ], 'Done') or return;
- $actions{$action}->($in, $dav, $all_hds);
+ $exit = $actions{$action}->($in, $dav, $all_hds);
}
%$dav_ = %$dav; #- applying
}
@@ -63,6 +65,7 @@ sub actions {
N_("Server") => \&ask_server,
N_("Mount point") => \&mount_point,
N_("Options") => \&options,
+ N_("Remove") => \&remove,
N_("Done") => sub {},
);
}
@@ -95,11 +98,23 @@ sub ask_server {
sub options {
my ($in, $dav, $all_hds) = @_;
diskdrake::interactive::Options($in, {}, $dav, $all_hds);
+ return;
}
+
+sub remove {
+ my ($in, $dav, $all_hds) = @_;
+ if ($in->ask_yesorno(N("Warning"), N("Are you sure you want to delete this mountpoint?"))) {
+ @{$all_hds->{davs}} = grep($_->{mntpoint} ne $dav->{mntpoint}, @{$all_hds->{davs}});
+ return 1;
+ }
+ return;
+}
+
sub mount_point {
my ($in, $dav, $all_hds) = @_;
my $proposition = $dav->{device} =~ /(\w+)/ ? "/mnt/$1" : "/mnt/dav";
diskdrake::interactive::Mount_point_raw_hd($in, $dav, $all_hds, $proposition);
+ return;
}
sub format_dav_info {
diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm
index 4568448c6..c2bd64023 100644
--- a/perl-install/diskdrake/hd_gtk.pm
+++ b/perl-install/diskdrake/hd_gtk.pm
@@ -1,4 +1,4 @@
-package diskdrake::hd_gtk; # $Id: hd_gtk.pm 257107 2009-04-27 15:25:10Z pterjan $
+package diskdrake::hd_gtk; # $Id: hd_gtk.pm 269772 2010-06-03 11:51:31Z pterjan $
use diagnostics;
use strict;
@@ -28,7 +28,7 @@ my ($w, @notebook, $done_button);
struct {
string name # which is displayed in tab of the notebook
bool no_auto # wether the kind can disappear after creation
- string type # one of { 'hd', 'raid', 'lvm', 'loopback', 'removable', 'nfs', 'smb' }
+ string type # one of { 'hd', 'raid', 'lvm', 'loopback', 'removable', 'nfs', 'smb', 'dmcrypt' }
hd | hd_lvm | part_raid[] | part_dmcrypt[] | part_loopback[] | raw_hd[] val
#
@@ -44,6 +44,13 @@ notebook current_kind[]
=cut
+sub load_theme {
+ my $rc = "/usr/share/libDrakX/diskdrake.rc";
+ -r $rc or $rc = dirname(__FILE__) . "/../diskdrake.rc";
+ -r $rc or $rc = dirname(__FILE__) . "/../share/diskdrake.rc";
+ Gtk2::Rc->parse($rc);
+}
+
sub main {
($in, $all_hds, $do_force_reload) = @_;
@@ -53,10 +60,8 @@ sub main {
$w = ugtk2->new(N("Partitioning"));
$::main_window = $w->{real_window} if !$::isEmbedded && !$::isInstall;
- my $rc = "/usr/share/libDrakX/diskdrake.rc";
- -r $rc or $rc = dirname(__FILE__) . "/../diskdrake.rc";
- -r $rc or $rc = dirname(__FILE__) . "/../share/diskdrake.rc";
- Gtk2::Rc->parse($rc);
+
+ load_theme();
# TODO
# is_empty_array_ref($all_hds->{raids}) or raid::stopAll;
@@ -162,8 +167,7 @@ sub add_kind2notebook {
sub interactive_help() {
if ($::isInstall) {
- my $func = $in->interactive_help_sub_display_id('diskdrake');
- $func and $func->();
+ $in->display_help({ interactive_help_id => 'diskdrake' }, $w);
} else {
require run_program;
run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'diskdrake');
@@ -250,10 +254,9 @@ sub current_kind_changed {
my $v = $kind->{val};
my @parts =
$kind->{type} eq 'raid' ? grep { $_ } @$v :
- $kind->{type} eq 'dmcrypt' ? @$v :
$kind->{type} eq 'loopback' ? @$v : fs::get::hds_fstab_and_holes($v);
my $totalsectors =
- $kind->{type} =~ /raid|dmcrypt|loopback/ ? sum(map { $_->{size} } @parts) : $v->{totalsectors};
+ $kind->{type} =~ /raid|loopback/ ? sum(map { $_->{size} } @parts) : $v->{totalsectors};
create_buttons4partitions($kind, $totalsectors, @parts);
}
@@ -280,7 +283,6 @@ sub create_automatic_notebooks {
$may_add->(hd2kind($_)) foreach @{$all_hds->{hds}};
$may_add->(lvm2kind($_)) foreach @{$all_hds->{lvms}};
$may_add->(raid2kind()) if @{$all_hds->{raids}};
- $may_add->(dmcrypt2kind()) if @{$all_hds->{dmcrypts}};
$may_add->(loopback2kind()) if @{$all_hds->{loopbacks}};
@notebook = grep_index {
@@ -313,7 +315,11 @@ sub create_buttons4partitions {
};
foreach my $entry (@parts) {
- my $info = $entry->{mntpoint};
+ if(isRawLUKS($entry) && $entry->{dm_active}) {
+ my $p = find { $entry->{dm_name} eq $_->{dmcrypt_name} } @{$all_hds->{dmcrypts}};
+ $entry = $p if $p;
+ }
+ my $info = $entry->{mntpoint} || $entry->{device_LABEL};
$info .= "\n" . ($entry->{size} ? formatXiB($entry->{size}, 512) : N("Unknown")) if $info;
my $w = Gtk2::ToggleButton->new_with_label($info) or internal_error('new_with_label');
$w->signal_connect(clicked => sub {
@@ -339,12 +345,15 @@ sub create_buttons4partitions {
last;
}
});
- my @colorized_fs_types = qw(ext3 ext4dev xfs swap vfat ntfs ntfs-3g);
+ if(isLUKS($entry) || isRawLUKS($entry)) {
+ $w->set_image(gtknew("Image", file => "security-strong"));
+ }
+ my @colorized_fs_types = qw(ext3 ext4 xfs swap vfat ntfs ntfs-3g);
$w->set_name("PART_" . (isEmpty($entry) ? 'empty' :
$entry->{fs_type} && member($entry->{fs_type}, @colorized_fs_types) ? $entry->{fs_type} :
'other'));
$w->set_size_request($entry->{size} * $ratio + $minwidth, 0);
- gtkpack__($kind->{display_box}, $w);
+ gtkpack($kind->{display_box}, $w);
if ($current_entry && fsedit::are_same_partitions($current_entry, $entry)) {
$set_current_button->($w);
$w->grab_focus;
@@ -357,7 +366,7 @@ sub create_buttons4partitions {
# disks: helpers
################################################################################
sub current_hd() {
- $current_kind->{type} =~ /hd|lvm/ or die 'current_hd called but $current_kind is not an hd';
+ $current_kind->{type} =~ /hd|lvm/ or die 'current_hd called but $current_kind is not an hd ('.$current_kind->{type}.')';
$current_kind->{val};
}
sub current_part() {
@@ -376,9 +385,9 @@ sub hd2kind {
}
sub filesystems_button_box() {
- my @types = (N_("Ext3"), N_("XFS"), N_("Swap"), arch() =~ /sparc/ ? N_("SunOS") : arch() eq "ppc" ? N_("HFS") : N_("Windows"),
+ my @types = (N_("Ext4"), N_("XFS"), N_("Swap"), arch() =~ /sparc/ ? N_("SunOS") : arch() eq "ppc" ? N_("HFS") : N_("Windows"),
N_("Other"), N_("Empty"));
- my %name2fs_type = (Ext3 => 'ext3', Ext4 => 'ext4dev', 'XFS' => 'xfs', Swap => 'swap', Other => 'other', "Windows" => 'vfat', HFS => 'hfs');
+ my %name2fs_type = (Ext3 => 'ext3', Ext4 => 'ext4', 'XFS' => 'xfs', Swap => 'swap', Other => 'other', "Windows" => 'vfat', HFS => 'hfs');
gtkpack(Gtk2::HBox->new(),
map {
@@ -436,13 +445,6 @@ sub raid2kind() {
################################################################################
# loopbacks: helpers
################################################################################
-sub dmcrypt2kind() {
- { type => 'dmcrypt', name => 'dmcrypt', val => $all_hds->{dmcrypts} };
-}
-
-################################################################################
-# loopbacks: helpers
-################################################################################
sub loopback2kind() {
{ type => 'loopback', name => 'loopback', val => $all_hds->{loopbacks} };
}
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index 5c184c9f4..e5e2090a7 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -1,4 +1,4 @@
-package diskdrake::interactive; # $Id: interactive.pm 246710 2008-09-26 09:24:08Z pixel $
+package diskdrake::interactive; # $Id: interactive.pm 269771 2010-06-03 11:50:24Z pterjan $
use diagnostics;
use strict;
@@ -41,6 +41,7 @@ struct part {
bool prefer_device_UUID # should the {device_UUID} or the {device} be used in fstab
bool prefer_device # should the {device} be used in fstab
bool faked_device # false if {device} is a real device, true for nfs/smb/dav/none devices. If the field does not exist, we do not know
+ bool device_LABEL_changed # true if device_LABEL is different from the one on the disk
string rootDevice # 'sda', 'hdc' ... (can also be a VG_name)
string real_mntpoint # directly on real /, '/tmp/hdimage' ...
@@ -49,13 +50,13 @@ struct part {
string device_windobe # 'C', 'D' ...
string encrypt_key # [0-9A-Za-z./]{20,}
string comment # comment to have in fstab
- string volume_label #
+ string volume_label #
bool is_removable # is the partition on a removable drive
bool isMounted
bool isFormatted
- bool notFormatted
+ bool notFormatted
# isFormatted means the device is formatted
# !isFormatted && notFormatted means the device is not formatted
# !isFormatted && !notFormatted means we do not know which state we're in
@@ -72,13 +73,13 @@ struct part {
string real_device # '/dev/loop0', '/dev/loop1' ... (used for encrypted loopback)
# internal CHS (Cylinder/Head/Sector)
- int start_cyl, start_head, start_sec, end_cyl, end_head, end_sec,
+ int start_cyl, start_head, start_sec, end_cyl, end_head, end_sec,
}
struct part_allocate inherits part {
int maxsize # in sectors (alike "size")
int min_hd_size # in sectors (do not allocate if the drive is smaller than the given size)
- int ratio #
+ int ratio #
string hd # 'hda', 'hdc'
string parts # for creating raid partitions. eg: 'foo bar' where 'foo' and 'bar' are mntpoint
}
@@ -121,7 +122,7 @@ struct partition_table_elem {
}
struct geom {
- int heads
+ int heads
int sectors
int cylinders
int totalcylinders # for SUN, forget it
@@ -138,7 +139,7 @@ struct hd {
bool readonly # is it allowed to modify the partition table
bool getting_rid_of_readonly_allowed # is it forbidden to write because the partition table is badly handled, or is it because we MUST not change the partition table
- bool isDirty # does it need to be written to the disk
+ bool isDirty # does it need to be written to the disk
list will_tell_kernel # list of actions to tell to the kernel so that it knows the new partition table
bool rebootNeeded # happens when a kernel reread failed
list partitionsRenumbered # happens when you
@@ -146,7 +147,9 @@ struct hd {
# - add an extended partition which is the first extended partition
list allPartitionsRenumbered # used to update bootloader configuration
int bus, id
-
+
+ bool is_removable # is it a removable drive
+
partition_table_elem primary
partition_table_elem extended[]
@@ -203,12 +206,12 @@ sub main {
}
my ($current_part, $current_hd);
-
+
while (1) {
my $choose_txt = $current_part ? N_("Choose another partition") : N_("Choose a partition");
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),
+ $current_part = $in->ask_from_listf('diskdrake', translate($choose_txt),
sub {
my $hd = fs::get::part2hd($_[0] || return, $all_hds);
format_part_info_short($hd, $_[0]);
@@ -220,33 +223,33 @@ sub main {
return if !$current_part;
my %actions = my @actions = (
- if_($current_part,
+ if_($current_part,
(map { my $s = $_; $_ => sub { $diskdrake::interactive::{$s}($in, $current_hd, $current_part, $all_hds) } } part_possible_actions($in, $current_hd, $current_part, $all_hds)),
'____________________________' => sub {},
),
if_(@$parts_and_holes > 1, $choose_txt => $choose_part),
if_($current_hd,
(map { my $s = $_; $_ => sub { $diskdrake::interactive::{$s}($in, $current_hd, $all_hds) } } hd_possible_actions_interactive($in, $current_hd, $all_hds)),
- ),
+ ),
(map { my $s = $_; $_ => sub { $diskdrake::interactive::{$s}($in, $all_hds) } } general_possible_actions($in, $all_hds)),
);
my ($actions) = list2kv(@actions);
my $a;
if ($current_part) {
$in->ask_from_({
- cancel => N("Exit"),
+ cancel => N("Exit"),
title => 'diskdrake',
messages => format_part_info($current_hd, $current_part),
},
[ { val => \$a, list => $actions, format => \&translate, type => 'list', sort => 0, gtk => { use_boxradio => 0 } } ]) or last;
my $v = eval { $actions{$a}() };
if (my $err = $@) {
- $in->ask_warn(N("Error"), formatError($err));
+ $in->ask_warn(N("Error"), formatError($err));
}
if ($v eq 'force_reload') {
$all_hds = $do_force_reload->();
}
- $current_hd = $current_part = '' if !is_part_existing($current_part, $all_hds);
+ $current_hd = $current_part = '' if !is_part_existing($current_part, $all_hds);
} else {
$choose_part->();
}
@@ -283,6 +286,9 @@ sub Done {
$in->ask_yesorno(N("Quit without saving"), N("Quit without writing the partition table?"), 1) or return;
}
}
+ foreach (@{$all_hds->{raids}}) {
+ raid::make($all_hds->{raids}, $_);
+ }
if (!$::isInstall) {
my $new = fs::fstab_to_string($all_hds);
if ($new ne $all_hds->{current_fstab} && $in->ask_yesorno(N("Confirmation"), N("Do you want to save /etc/fstab modifications"), 1)) {
@@ -309,8 +315,8 @@ Quit anyway?", $part->{device}, $part->{mntpoint})) or return if $::isStandalone
################################################################################
sub hd_possible_actions_base {
my ($hd) = @_;
- (
- if_(!$hd->{readonly} || $hd->{getting_rid_of_readonly_allowed}, N_("Clear all")),
+ (
+ if_(!$hd->{readonly} || $hd->{getting_rid_of_readonly_allowed}, N_("Clear all")),
if_(!$hd->{readonly} && $::isInstall, N_("Auto allocate")),
);
}
@@ -361,9 +367,9 @@ sub Auto_allocate {
if ($@) {
$@ =~ /partition table already full/ or die;
- $in->ask_warn("", [
+ $in->ask_warn("", [
N("All primary partitions are used"),
- N("I can not add any more partitions"),
+ N("I can not add any more partitions"),
N("To have more partitions, please delete one to be able to create an extended partition"),
]);
}
@@ -394,12 +400,13 @@ sub part_possible_actions {
$part or return;
my %actions = my @l = (
+ N_("View") => '!isSwap && !isNonMountable && maybeFormatted',
N_("Mount point") => '$part->{real_mntpoint} || (!isBusy && !isSwap && !isNonMountable)',
N_("Type") => '!isBusy && $::expert && (!readonly || $part->{pt_type} == 0x83)',
N_("Options") => '!isSwap($part) && !isNonMountable && $::expert',
- N_("Label") => '!isNonMountable && $::expert',
+ N_("Label") => '!isNonMountable && $::expert && fs::format::canEditLabel($part)',
N_("Resize") => '!isBusy && !readonly && !isSpecial || isLVM($hd) && LVM_resizable',
- N_("Format") => '!isBusy && (!readonly && ($::expert || $::isStandalone) || fs::type::isRawLUKS($part))',
+ N_("Format") => '!isBusy && !isRawLVM && !isPartOfLVM && (!readonly && ($::expert || $::isStandalone) || fs::type::isRawLUKS($part))',
N_("Mount") => '!isBusy && (hasMntpoint || isSwap) && maybeFormatted && ($::expert || $::isStandalone)',
N_("Add to RAID") => '!isBusy && isRawRAID && (!isSpecial || isRAID)',
N_("Add to LVM") => '!isBusy && isRawLVM',
@@ -417,16 +424,16 @@ sub part_possible_actions {
my %macros = (
readonly => '$hd->{readonly}',
hasMntpoint => '$part->{mntpoint}',
- LVM_resizable => '$part->{fs_type} eq "reiserfs" || (isMounted ? $part->{fs_type} eq "xfs" : member($part->{fs_type}, qw(ext3 ext4dev)))',
+ LVM_resizable => 'member($part->{fs_type}, qw(reiserfs xfs ext3 ext4 btrfs))',
canModifyRAID => 'isPartOfRAID($part) && !isMounted(fs::get::device2part($part->{raid}, $all_hds->{raids}))',
);
if (isEmpty($part)) {
if_(!$hd->{readonly}, N_("Create"));
} elsif ($part->{pt_type} == 0xbf && detect_devices::is_xbox()) {
#- XBox OS partitions, do not allow anything
- return;
+ return;
} else {
- grep {
+ grep {
my $cond = $actions{$_};
while (my ($k, $v) = each %macros) {
$cond =~ s/$k/qq(($v))/e;
@@ -437,10 +444,20 @@ sub part_possible_actions {
}
}
-#- in case someone use diskdrake only to create partitions,
+sub View {
+ my ($in, $hd, $part, $all_hds) = @_;
+ my $handle = any::inspect($part, $::prefix);
+ if ($handle) {
+ $in->ask_directory({'directory'=>$handle->{dir}});
+ } else {
+ $in->ask_warn(N("Error"), N("Failed to mount partition"));
+ }
+}
+
+#- in case someone use diskdrake only to create partitions,
#- ie without assigning a mount point,
#- do not suggest mount points anymore
-my $do_suggest_mount_point = 1;
+my $do_suggest_mount_point = $::isInstall;
sub Create {
my ($in, $hd, $part, $all_hds) = @_;
@@ -451,7 +468,7 @@ sub Create {
$part->{mntpoint} = '' if !$do_suggest_mount_point;
} else {
$part->{size} = $part->{maxsize};
- fs::type::suggest_fs_type($part, 'ext3');
+ fs::type::suggest_fs_type($part, defaultFS());
}
if (isLVM($hd)) {
lvm::suggest_lv_name($hd, $part);
@@ -464,18 +481,20 @@ sub Create {
my $type_name = fs::type::part2type_name($part);
my $mb_size = to_Mb($part->{size});
my $has_startsector = ($::expert || arch() !~ /i.86/) && !isLVM($hd);
+ my $use_dmcrypt;
+ my $requested_type;
$in->ask_from(N("Create a new partition"), '',
[
{ label => N("Create a new partition"), title => 1 },
if_($has_startsector,
- { label => N("Start sector: "), val => \$part->{start}, min => $def_start, max => ($max - min_partition_size($hd)),
+ { label => N("Start sector: "), val => \$part->{start}, min => $def_start, max => ($max - min_partition_size($hd)),
type => 'range', SpinButton => $::expert, changed => sub { $mb_size = min($mb_size, to_Mb($max - $part->{start})) } },
),
- { label => N("Size in MB: "), val => \$mb_size, min => to_Mb(min_partition_size($hd)), max => to_Mb($def_size),
+ { label => N("Size in MB: "), val => \$mb_size, min => to_Mb(min_partition_size($hd)), max => to_Mb($def_size),
type => 'range', SpinButton => $::expert, changed => sub { $part->{start} = min($part->{start}, $max - $mb_size * 2048) } },
- { label => N("Filesystem type: "), val => \$type_name, list => [ fs::type::type_names($::expert, $hd) ],
- sort => 0, if_($::expert, gtk => { wrap_width => 4 }, do_not_ellipsize => 1) },
+ { label => N("Filesystem type: "), val => \$type_name, list => [ fs::type::type_names($::expert, $hd) ],
+ sort => 0, if_($::expert, gtk => { wrap_width => 2 }, do_not_ellipsize => 1) },
{ label => N("Mount point: "), val => \$part->{mntpoint}, list => [ fsedit::suggestions_mntpoint($all_hds), '' ],
disabled => sub { my $p = fs::type::type_name2subpart($type_name); isSwap($p) || isNonMountable($p) }, type => 'combo', not_edit => 0,
},
@@ -485,19 +504,36 @@ sub Create {
if_($::expert && isLVM($hd),
{ label => N("Logical volume name "), val => \$part->{lv_name}, list => [ qw(root swap usr home var), '' ], sort => 0, not_edit => 0 },
),
+ { label => N("Encrypt partition"), type => 'bool', val => \$use_dmcrypt },
+ { label => N("Encryption key "), val => \$part->{dmcrypt_key}, disabled => sub { !$use_dmcrypt }, hidden => 1, weakness_check => 1 },
+ { label => N("Encryption key (again)"), val => \$part->{dmcrypt_key2}, disabled => sub { !$use_dmcrypt }, hidden => 1 },
], 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
- put_in_hash($part, fs::type::type_name2subpart($type_name));
$do_suggest_mount_point = 0 if !$part->{mntpoint};
+ put_in_hash($part, fs::type::type_name2subpart($type_name));
$part->{mntpoint} = '' if isNonMountable($part);
$part->{mntpoint} = 'swap' if isSwap($part);
fs::mount_options::set_default($part, ignore_is_removable => 1);
+ # if user asked to encrypt the partition, use dm-crypt and create requested fs inside
+ if ($use_dmcrypt) {
+ my $err;
+ $err = N("The encryption keys do not match") unless ($part->{dmcrypt_key} eq $part->{dmcrypt_key2});
+ $err = N("Missing encryption key") unless ($part->{dmcrypt_key});
+ if ($err) {
+ $in->ask_warn(N("Error"), $err);
+ return 1;
+ }
+ $requested_type = $type_name;
+ $type_name = 'Encrypted';
+ }
+
+ put_in_hash($part, fs::type::type_name2subpart($type_name));
check($in, $hd, $part, $all_hds) or return 1;
$migrate_files = need_migration($in, $part->{mntpoint}) or return 1;
-
+
my $seen;
- eval {
+ eval {
catch_cdie { fsedit::add($hd, $part, $all_hds, { force => 1, primaryOrExtended => $primaryOrExtended }) }
sub { $seen = 1; $in->ask_okcancel('', formatError($@)) };
};
@@ -516,9 +552,32 @@ First remove a primary partition and create an extended partition."));
},
) or return;
+ if ($use_dmcrypt) {
+ write_partitions($in, $hd) or return;
+ # Initialize it and format it
+ dmcrypt_format($in, $hd, $part, $all_hds);
+ my $p = find { $part->{dm_name} eq $_->{dmcrypt_name} } @{$all_hds->{dmcrypts}};
+ my $p2 = fs::type::type_name2subpart($requested_type);
+ $p->{fs_type} = $p2->{fs_type};
+ $p->{type_name} = $requested_type;
+ $p->{mntpoint} = $part->{mntpoint};
+ $part->{mntpoint} = '';
+ if ($::isStandalone) {
+ fs::format::check_package_is_installed_format($in->do_pkgs, $p->{fs_type}) or log::l("Missing package");
+ }
+ if ($::expert && !member($p->{fs_type}, 'reiserfs', 'reiser4', 'xfs', 'hfs', 'ntfs', 'ntfs-3g')) {
+ $p->{toFormatCheck} = $in->ask_yesorno(N("Confirmation"), N("Check bad blocks?"));
+ }
+ $p->{isFormatted} = 0; #- force format;
+ # Wait for the newly created device to appear before formatting it
+ my ($_w, $wait_message) = $in->wait_message_with_progress_bar;
+ fs::format::part($all_hds, $p, $wait_message) unless isRawLVM($p);
+ }
+
warn_if_renumbered($in, $hd);
if ($migrate_files eq 'migrate') {
+ # FIXME check encrypt case
format_($in, $hd, $part, $all_hds) or return;
migrate_files($in, $hd, $part);
fs::mount::part($part);
@@ -527,6 +586,11 @@ First remove a primary partition and create an extended partition."));
sub Delete {
my ($in, $hd, $part, $all_hds) = @_;
+ if (fs::type::isLUKS($part)) {
+ my $p = find { $_->{dm_name} eq $part->{dmcrypt_name} } partition_table::get_normal_parts($hd);
+ RemoveFromDm($in, $hd, $p, $all_hds);
+ $part = $p;
+ }
if (isRAID($part)) {
raid::delete($all_hds->{raids}, $part);
} elsif (isLVM($hd)) {
@@ -553,41 +617,50 @@ sub Type {
my ($in, $hd, $part) = @_;
my $warned;
- my $warn = sub {
- $warned = 1;
- ask_alldatawillbelost($in, $part, N_("After changing type of partition %s, all data on this partition will be lost"));
+ my $warn = sub {
+ $warned = 1;
+ if (maybeFormatted($part)) {
+ ask_alldatawillbelost($in, $part, N_("After changing type of partition %s, all data on this partition will be lost"));
+ } else {
+ 1;
+ }
};
- #- for ext2, warn after choosing as ext2->ext3 can be achieved without loosing any data :)
- $part->{fs_type} eq 'ext2' || $part->{fs_type} =~ /ntfs/ or $warn->() or return;
+ #- for ext2/ext3, warn after choosing as ext2->ext3 and ext*->ext4 can be achieved without loosing any data :)
+ member($part->{fs_type}, qw(ext2 ext3)) || $part->{fs_type} =~ /ntfs/ or $warn->() or return;
my @types = fs::type::type_names($::expert, $hd);
#- when readonly, Type() is allowed only when changing {fs_type} but not {pt_type}
- #- eg: switching between ext2, ext3, ext4dev, reiserfs...
+ #- eg: switching between ext2, ext3, ext4, reiserfs...
@types = grep { fs::type::type_name2pt_type($_) == $part->{pt_type} } @types if $hd->{readonly};
my $type_name = fs::type::part2type_name($part);
$in->ask_from_({ title => N("Change partition type") },
[
{ label => N("Which filesystem do you want?"), title => 1 },
- { label => N("Type"), val => \$type_name, list => \@types, sort => 0, do_not_ellipsize => 1,
- focus => sub { 1 }, not_edit => 1, gtk => { wrap_width => 4 } } ]) or return;
+ { label => N("Type"), val => \$type_name, type => 'list', list => \@types, sort => 1, do_not_ellipsize => 1,
+ focus => sub { 1 }, not_edit => 1, gtk => { wrap_width => 2 } } ]) or return;
my $type = $type_name && fs::type::type_name2subpart($type_name);
- if (member($type->{fs_type}, qw(ext2 ext3 ext4dev))) {
+ if ($part->{fs_type} eq 'ext2' && $type->{fs_type} eq 'ext3') {
my $_w = $in->wait_message(N("Please wait"), N("Switching from %s to %s", 'ext2', $type->{fs_type}));
if (run_program::run("tune2fs", "-j", devices::make($part->{device}))) {
put_in_hash($part, $type);
set_isFormatted($part, 1); #- assume that if tune2fs works, partition is formatted
#- disable the fsck (do not do it together with -j in case -j fails?)
- fs::format::disable_forced_fsck($part->{device});
+ fs::format::disable_forced_fsck($part->{device});
return;
}
+ } elsif (member($part->{fs_type}, qw(ext2 ext3)) && $type->{fs_type} eq 'ext4') {
+ # FIXME enable some nice flags
+ put_in_hash($part, $type);
+ return;
} elsif ($type->{fs_type} =~ /ntfs/ && $part->{fs_type} =~ /ntfs/) {
if ($type->{fs_type} eq 'ntfs-3g') {
+ local $::prefix = ''; # For draklive-install
$in->do_pkgs->ensure_binary_is_installed('ntfs-3g', 'mount.ntfs-3g') or return;
}
put_in_hash($part, $type);
@@ -603,12 +676,25 @@ sub Type {
sub Label {
my ($in, $_hd, $part) = @_;
- $in->ask_from(N("Which volume label?"), '',
+ my $new_label = $part->{device_LABEL} || "";
- [
+ write_partitions($in, $_hd) or return;
+
+ $in->ask_from(N("Set volume label"),
+ maybeFormatted($part) ?
+ N("Beware, this will be written to disk as soon as you validate!")
+ : N("Beware, this will be written to disk only after formatting!"),
+ [
{ label => N("Which volume label?"), title => 1 },
- { label => N("Label:"), val => \$part->{device_LABEL} } ]) or return;
- $part->{prefer_device_LABEL} = to_bool($part->{device_LABEL});
+ { label => N("Label:"), val => \$new_label } ]) or return;
+
+ fs::format::check_package_is_installed_label($in->do_pkgs, $part->{fs_type}) or return;
+ $part->{prefer_device_LABEL} = to_bool($part->{device_LABEL}) && !isLVM($part);
+ return if $new_label eq $part->{device_LABEL};
+ $part->{device_LABEL} = $new_label;
+ $part->{device_LABEL_changed} = 1;
+ fs::format::clean_label($part);
+ fs::format::write_label($part);
}
sub Mount_point {
@@ -626,7 +712,7 @@ sub Mount_point {
$in->ask_from_({
callbacks => {
complete => sub {
- !isPartOfLoopback($part) || $mntpoint or $in->ask_warn(N("Error"),
+ !isPartOfLoopback($part) || $mntpoint or $in->ask_warn(N("Error"),
N("Can not unset mount point as this partition is used for loop back.
Remove the loopback first")), return 1;
$part->{mntpoint} eq $mntpoint || check_mntpoint($in, $mntpoint, $part, $all_hds) or return 1;
@@ -636,8 +722,8 @@ Remove the loopback first")), return 1;
},
[
{ label => $msg, title => 1 },
- { label => N("Mount point"), val => \$mntpoint,
- list => [ uniq(if_($mntpoint, $mntpoint), fsedit::suggestions_mntpoint($all_hds), '') ],
+ { label => N("Mount point"), val => \$mntpoint,
+ list => [ uniq(if_($mntpoint, $mntpoint), fsedit::suggestions_mntpoint($all_hds), '') ],
focus => sub { 1 },
not_edit => 0 } ],
) or return;
@@ -658,8 +744,8 @@ sub Mount_point_raw_hd {
'',
[
{ label => N("Where do you want to mount %s?", $part->{device}), title => 1 },
- { label => N("Mount point"), val => \$mntpoint,
- list => [ if_($mntpoint, $mntpoint), '', @propositions ],
+ { label => N("Mount point"), val => \$mntpoint,
+ list => [ if_($mntpoint, $mntpoint), '', @propositions ],
not_edit => 0 } ],
complete => sub {
$part->{mntpoint} eq $mntpoint || check_mntpoint($in, $mntpoint, $part, $all_hds) or return 1;
@@ -672,7 +758,13 @@ sub Mount_point_raw_hd {
sub Resize {
my ($in, $hd, $part) = @_;
my (%nice_resize);
- my ($min, $max) = (min_partition_size($hd), max_partition_resize($hd, $part));
+ my $low_part = $part;
+
+ if (isLUKS($part)) {
+ $low_part = find { $_->{dm_name} eq $part->{dmcrypt_name} } partition_table::get_normal_parts($hd);
+ }
+
+ my ($min, $max) = (min_partition_size($hd), max_partition_resize($hd, $low_part));
if (maybeFormatted($part)) {
# here we may have a non-formatted or a formatted partition
@@ -686,8 +778,8 @@ sub Resize {
require resize_fat::main;
$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 (member($part->{fs_type}, qw(ext2 ext3 ext4dev))) {
+ $max = min($max, $nice_resize{fat}->max_size);
+ } elsif (member($part->{fs_type}, qw(ext2 ext3 ext4))) {
write_partitions($in, $hd) or return;
require diskdrake::resize_ext2;
if ($nice_resize{ext2} = diskdrake::resize_ext2->new($part->{device}, devices::make($part->{device}))) {
@@ -704,15 +796,21 @@ sub Resize {
} elsif ($part->{fs_type} eq 'reiserfs') {
write_partitions($in, $hd) or return;
if ($part->{isMounted}) {
- $nice_resize{reiserfs} = 1;
+ $nice_resize{reiserfs} = 1;
$min = $part->{size}; #- ensure the user can only increase
} elsif (defined(my $free = fs::df($part))) {
- $nice_resize{reiserfs} = 1;
+ $nice_resize{reiserfs} = 1;
$min = max($min, $part->{size} - $free);
}
} elsif ($part->{fs_type} eq 'xfs' && isLVM($hd) && $::isStandalone && $part->{isMounted}) {
$min = $part->{size}; #- ensure the user can only increase
$nice_resize{xfs} = 1;
+ } elsif ($part->{fs_type} eq 'btrfs') {
+ write_partitions($in, $hd) or return;
+ if (defined(my $free = fs::df($part))) {
+ $nice_resize{btrfs} = 1;
+ $min = max($min, $part->{size} - $free);
+ }
}
#- make sure that even after normalizing the size to cylinder boundaries, the minimun will be saved,
#- this save at least a cylinder (less than 8Mb).
@@ -730,7 +828,7 @@ sub Resize {
my $mb_size = to_Mb($part->{size});
my ($gmin, $gmax) = (to_Mb($min), to_Mb($max));
- $in->ask_from(N("Resize"), '', [
+ $in->ask_from(N("Resize"), '', [
{ label => N("Choose the new size"), title => 1 },
{ label => N("New size in MB: "), val => \$mb_size, min => $gmin, max => $gmax, type => 'range', SpinButton => $::expert },
{ label => N("Minimum size: %s MB", $gmin) },
@@ -742,8 +840,8 @@ sub Resize {
$part->{size} == $size and return;
my $oldsize = $part->{size};
- $part->{size} = $size;
- $hd->adjustEnd($part);
+ $low_part->{size} = $part->{size} = $size;
+ $hd->adjustEnd($low_part);
undef $@;
my $_b = before_leaving { $@ and $part->{size} = $oldsize };
@@ -752,12 +850,18 @@ sub Resize {
my ($write_partitions) = @_;
if (isLVM($hd)) {
- lvm::lv_resize($part, $oldsize);
+ lvm::lv_resize($low_part, $oldsize);
} else {
- partition_table::will_tell_kernel($hd, resize => $part);
- partition_table::adjust_local_extended($hd, $part);
+ if ($write_partitions && isLUKS($part)) {
+ run_program::run('cryptsetup', 'luksClose', $part->{dmcrypt_name}) or die ("Failed to resize partition, maybe it is mounted");
+ }
+ partition_table::will_tell_kernel($hd, resize => $low_part);
+ partition_table::adjust_local_extended($hd, $low_part);
partition_table::adjust_main_extended($hd);
write_partitions($in, $hd) or return if $write_partitions && %nice_resize;
+ if ($write_partitions && isLUKS($part)) {
+ fs::dmcrypt::open_part([], $low_part);
+ }
}
1;
};
@@ -775,7 +879,7 @@ sub Resize {
log::l("ntfs resize to $part->{size} sectors");
$nice_resize{ntfs}->resize($part->{size});
$wait = undef;
- $in->ask_warn(N("Warning"), N("To ensure data integrity after resizing the partition(s),
+ $in->ask_warn(N("Warning"), N("To ensure data integrity after resizing the partition(s),
filesystem checks will be run on your next boot into Microsoft Windows®"));
} elsif ($nice_resize{reiserfs}) {
log::l("reiser resize to $part->{size} sectors");
@@ -783,6 +887,21 @@ filesystem checks will be run on your next boot into Microsoft Windows®"));
} elsif ($nice_resize{xfs}) {
#- happens only with mounted LVM, see above
run_program::run_or_die("xfs_growfs", $part->{mntpoint});
+ } elsif ($nice_resize{btrfs}) {
+ my $dir = "/tmp/tmp_resize_btrfs.$$";
+ if ($part->{isMounted}) {
+ $dir = ($::prefix || '') . $part->{mntpoint};
+ } else {
+ mkdir_p($dir);
+ fs::mount::mount(devices::make($part->{device}), $dir, $part->{fs_type});
+ }
+ if (!run_program::run("btrfsctl", "-r", $part->{size}*512, $dir)) {
+ $nice_resize{btrfs} = undef;
+ if (!$part->{isMounted}) {
+ fs::mount::umount($dir);
+ unlink($dir);
+ }
+ }
}
if (%nice_resize) {
@@ -795,6 +914,7 @@ filesystem checks will be run on your next boot into Microsoft Windows®"));
$adjust->(0) if $size < $oldsize;
}
+
sub Format {
my ($in, $hd, $part, $all_hds) = @_;
format_($in, $hd, $part, $all_hds);
@@ -823,9 +943,9 @@ sub dmcrypt_open {
if (!$part->{dmcrypt_key}) {
$in->ask_from_({
- title => N("Filesystem encryption key"),
+ title => N("Filesystem encryption key"),
messages => N("Enter your filesystem encryption key"),
- }, [ { label => N("Encryption key"), val => \$part->{dmcrypt_key},
+ }, [ { label => N("Encryption key"), val => \$part->{dmcrypt_key},
hidden => 1, focus => sub { 1 } } ]) or return;
}
@@ -856,6 +976,7 @@ sub Add2RAID {
sub Add2LVM {
my ($in, $hd, $part, $all_hds) = @_;
my $lvms = $all_hds->{lvms};
+ my @lvm_names = map { $_->{VG_name} } @$lvms;
write_partitions($in, $_) or return foreach isRAID($part) ? @{$all_hds->{hds}} : $hd;
my $lvm = $in->ask_from_listf_(N("Add to LVM"), N("Choose an existing LVM to add to"),
@@ -864,8 +985,23 @@ sub Add2LVM {
require lvm;
if (!ref $lvm) {
# create new lvm
- # FIXME: when mdv2006 is out: remove the question mark from the dialog title
- my $name = $in->ask_from_entry(N("LVM name?"), N("LVM name?")) or return;
+ my $n = 0;
+ while (member("vg$n", @lvm_names)) {
+ $n++;
+ }
+
+ my $name = "vg$n";
+ $in->ask_from_({ title => N("LVM name"),
+ messages => N("Enter a name for the new LVM volume group"),
+ focus_first => 1,
+ ok_disabled => sub { !$name },
+ validate => sub {
+ member($name, @lvm_names) or return 1;
+ $in->ask_warn(N("Error"), N("\"%s\" already exists", $name));
+ return 0;
+ } },
+ [{label=>N("LVM name"),val=> \$name}]) or return;
+
$lvm = new lvm($name);
push @$lvms, $lvm;
}
@@ -877,11 +1013,11 @@ sub Unmount {
my ($_in, $_hd, $part) = @_;
fs::mount::umount_part($part);
}
-sub RemoveFromRAID {
+sub RemoveFromRAID {
my ($_in, $_hd, $part, $all_hds) = @_;
raid::removeDisk($all_hds->{raids}, $part);
}
-sub RemoveFromDm {
+sub RemoveFromDm {
my ($_in, $_hd, $part, $all_hds) = @_;
fs::dmcrypt::close_part($all_hds->{dmcrypts}, $part);
}
@@ -903,7 +1039,7 @@ Do you want to move used physical extents on this volume to other volumes?", $pa
$all_hds->{lvms} = $other_lvms;
}
}
-sub ModifyRAID {
+sub ModifyRAID {
my ($in, $_hd, $part, $all_hds) = @_;
modifyRAID($in, $all_hds->{raids}, fs::get::device2part($part->{raid}, $all_hds->{raids}));
}
@@ -919,7 +1055,7 @@ sub Loopback {
my $part = { maxsize => $max, size => 0, loopback_device => $real_part, notFormatted => 1 };
if (!fsedit::suggest_part($part, $all_hds)) {
$part->{size} = $part->{maxsize};
- fs::type::suggest_fs_type($part, 'ext3');
+ fs::type::suggest_fs_type($part, defaultFS());
}
delete $part->{mntpoint}; # we do not want the suggested mntpoint
@@ -965,13 +1101,13 @@ sub Options {
relatime => sub { $options->{noatime} = 0 },
noatime => sub { $options->{relatime} = 0 },
);
-
+
$in->ask_from(N("Mount options"),
'',
- [
+ [
{ label => N("Mount options"), title => 1 },
- (map {
+ (map {
{ label => $_, text => scalar warp_text(formatAlaTeX($help{$_}), 60), val => \$options->{$_}, hidden => scalar(/password/),
advanced => !$part->{rootDevice} && !member($_, @simple_options), if_(!/=$/, type => 'bool'),
if_($callbacks{$_}, changed => $callbacks{$_}),
@@ -983,27 +1119,6 @@ sub Options {
if (($options->{usrquota} || $options->{grpquota}) && !$::isInstall) {
$in->do_pkgs->ensure_binary_is_installed('quota', 'quotacheck');
}
- if ($options->{encrypted}) {
- # modify $part->{options} for the check
- local $part->{options};
- fs::mount_options::pack($part, $options, $unknown);
- if (!check($in, $hd, $part, $all_hds)) {
- $options->{encrypted} = 0;
- } elsif (!$part->{encrypt_key} && !isSwap($part)) {
- if (my ($encrypt_key, $encrypt_algo) = choose_encrypt_key($in, $options, '')) {
- $options->{'encryption='} = $encrypt_algo;
- $part->{encrypt_key} = $encrypt_key;
- } else {
- $options->{encrypted} = 0;
- }
- }
- #- don't be sure of anything
- set_isFormatted($part, 0);
- $part->{notFormatted} = 0;
- } else {
- delete $options->{'encryption='};
- delete $part->{encrypt_key};
- }
}) or return;
fs::mount_options::pack($part, $options, $unknown);
@@ -1011,8 +1126,8 @@ sub Options {
}
-{
- no strict;
+{
+ no strict;
*{'Toggle to normal mode'} = sub() { $::expert = 0 };
*{'Toggle to expert mode'} = sub() { $::expert = 1 };
*{'Clear all'} = \&Clear_all;
@@ -1020,11 +1135,11 @@ sub Options {
*{'Mount point'} = \&Mount_point;
*{'Modify RAID'} = \&ModifyRAID;
*{'Add to RAID'} = \&Add2RAID;
- *{'Remove from RAID'} = \&RemoveFromRAID;
+ *{'Remove from RAID'} = \&RemoveFromRAID;
*{'Use'} = \&dmcrypt_open;
- *{'Remove from dm'} = \&RemoveFromDm;
+ *{'Remove from dm'} = \&RemoveFromDm;
*{'Add to LVM'} = \&Add2LVM;
- *{'Remove from LVM'} = \&RemoveFromLVM;
+ *{'Remove from LVM'} = \&RemoveFromLVM;
*{'Use for loopback'} = \&Loopback;
*{'Hard drive information'} = \&Hd_info;
}
@@ -1045,7 +1160,7 @@ sub modifyRAID {
$in->ask_from(N("Options"), '',
[
{ label => N("device"), val => \$new_device, list => [ $md_part->{device}, raid::free_mds($raids) ], sort => 0 },
-{ label => N("level"), val => \$md_part->{level}, list => [ qw(0 1 4 5 6 linear) ] },
+{ label => N("level"), val => \$md_part->{level}, list => [ qw(0 1 4 5 6 10 linear) ] },
{ label => N("chunk size in KiB"), val => \$md_part->{'chunk-size'} },
],
) or return;
@@ -1063,7 +1178,7 @@ sub ask_alldatamaybelost {
#- here we may have a non-formatted or a formatted partition
#- -> doing as if it was formatted
- $in->ask_okcancel(N("Read carefully"),
+ $in->ask_okcancel(N("Read carefully"),
[ N("Be careful: this operation is dangerous."), sprintf(translate($msg), $part->{device}) ], 1);
}
sub ask_alldatawillbelost {
@@ -1078,7 +1193,7 @@ sub ask_alldatawillbelost {
sub partitions_suggestions {
my ($in) = @_;
- my $t = $::expert ?
+ my $t = $::expert ?
$in->ask_from_list_(N("Partitioning Type"), N("What type of partitioning?"), [ keys %fsedit::suggestions ]) :
'simple';
$fsedit::suggestions{$t};
@@ -1092,14 +1207,14 @@ sub check_type {
return;
}
if ($::isStandalone && $type->{fs_type} && fs::format::known_type($type)) {
- fs::format::check_package_is_installed($in->do_pkgs, $type->{fs_type}) or return;
+ fs::format::check_package_is_installed_format($in->do_pkgs, $type->{fs_type}) or return;
}
1;
}
sub check_mntpoint {
my ($in, $mntpoint, $part, $all_hds) = @_;
my $seen;
- eval {
+ eval {
catch_cdie { fsedit::check_mntpoint($mntpoint, $part, $all_hds) }
sub { $seen = 1; $in->ask_okcancel(N("Error"), formatError($@)) };
};
@@ -1130,17 +1245,14 @@ sub write_partitions {
partition_table::write($hd) if !$::testing;
check_rebootNeeded($in, $hd) if !$b_skip_check_rebootNeeded;
# fix resizing's failures due to udev's race when writing the partition table
- run_program::run('udevadm', 'settle');
+ run_program::run('udevadm', 'settle') unless $::isInstall;
1;
}
sub ensure_we_have_encrypt_key_if_needed {
my ($in, $part) = @_;
- if ($part->{options} =~ /encrypted/ && !$part->{encrypt_key}) {
- my ($options, $_unknown) = fs::mount_options::unpack($part);
- $part->{encrypt_key} = choose_encrypt_key($in, $options, 'skip_encrypt_algo') or return;
- } elsif (fs::type::isRawLUKS($part)) {
+ if (fs::type::isRawLUKS($part)) {
$part->{dmcrypt_key} ||= choose_encrypt_key($in, {}, 'skip_encrypt_algo') or return;
}
1;
@@ -1167,9 +1279,9 @@ sub format_ {
return &dmcrypt_format;
}
if ($::isStandalone) {
- fs::format::check_package_is_installed($in->do_pkgs, $part->{fs_type}) or return;
+ fs::format::check_package_is_installed_format($in->do_pkgs, $part->{fs_type}) or return;
}
- if ($::expert && !member($part->{fs_type}, 'reiserfs', 'xfs')) {
+ if ($::expert && !member($part->{fs_type}, 'reiserfs', 'reiser4', 'xfs', 'hfs', 'ntfs', 'ntfs-3g')) {
$part->{toFormatCheck} = $in->ask_yesorno(N("Confirmation"), N("Check bad blocks?"));
}
$part->{isFormatted} = 0; #- force format;
@@ -1189,12 +1301,12 @@ sub need_migration {
(%s)
You can either choose to move the files into the partition that will be mounted there or leave them where they are (which results in hiding them by the contents of the mounted partition)",
- $mntpoint, formatList(5, @l)),
+ $mntpoint, formatList(5, @l)),
[ { val => \$choice, list => \@choices, type => 'list', format => sub { translate($_[0]) } } ]) or return;
$choice eq $choices[0] ? 'migrate' : 'hide';
} else {
'hide';
- }
+ }
}
sub migrate_files {
@@ -1204,11 +1316,11 @@ sub migrate_files {
my $handle = any::inspect($part, '', 'rw');
my @l = glob_("$part->{mntpoint}/*");
foreach (@l) {
- $wait->set(N("Copying %s", $_));
+ $wait->set(N("Copying %s", $_));
system("cp", "-a", $_, $handle->{dir}) == 0 or die "copying failed";
}
foreach (@l) {
- $wait->set(N("Removing %s", $_));
+ $wait->set(N("Removing %s", $_));
system("rm", "-rf", $_) == 0 or die "removing files failed";
}
}
@@ -1220,7 +1332,7 @@ sub warn_if_renumbered {
push @{$hd->{allPartitionsRenumbered}}, @$l;
- my @l = map {
+ my @l = map {
my ($old, $new) = @$_;
N("partition %s is now known as %s", $old, $new) } @$l;
$in->ask_warn(N("Warning"), join("\n", N("Partitions have been renumbered: "), @l));
@@ -1249,7 +1361,7 @@ sub format_part_info {
$info .= N("Mount point: ") . "$part->{mntpoint}\n" if $part->{mntpoint};
$info .= N("Device: ") . "$part->{device}\n" if $part->{device} && !isLoopback($part);
- $info .= N("Volume label: ") . "$part->{device_LABEL}\n" if $part->{device_LABEL} && $::expert;
+ $info .= N("Volume label: ") . "$part->{device_LABEL}\n" if $part->{device_LABEL};
$info .= N("UUID: ") . "$part->{device_UUID}\n" if $::expert && $part->{device_UUID};
$info .= N("DOS drive letter: %s (just a guess)\n", $part->{device_windobe}) if $part->{device_windobe};
if (arch() eq "ppc") {
@@ -1277,10 +1389,13 @@ sub format_part_info {
$info .= N("Not formatted\n") if !$part->{isFormatted} && $part->{notFormatted};
$info .= N("Mounted\n") if $part->{isMounted};
$info .= N("RAID %s\n", $part->{raid}) if isPartOfRAID($part);
- if (fs::type::isRawLUKS($part)) {
- $info .= N("Encrypted") . ($part->{dm_active} && $part->{dm_name} ? N(" (mapped on %s)", $part->{dm_name}) :
- $part->{dm_name} ? N(" (to map on %s)", $part->{dm_name}) :
- N(" (inactive)")) . "\n";
+ if (fs::type::isRawLUKS($part) || fs::type::isLUKS($part)) {
+ $info .= N("Encrypted")."\n";
+ if (fs::type::isRawLUKS($part)) {
+ $info .= ($part->{dm_active} && $part->{dm_name} ? N(" (mapped on %s)", $part->{dm_name}) :
+ $part->{dm_name} ? N(" (to map on %s)", $part->{dm_name}) :
+ N(" (inactive)")) . "\n";
+ }
}
if (isPartOfLVM($part)) {
$info .= sprintf "LVM %s\n", $part->{lvm};
@@ -1306,7 +1421,7 @@ sub format_part_info {
$info;
}
-sub format_part_info_short {
+sub format_part_info_short {
my ($hd, $part) = @_;
isEmpty($part) ? N("Free space on %s (%s)", $hd->{device}, formatXiB($part->{size}, 512))
: partition_table::description($part);
@@ -1367,9 +1482,9 @@ sub choose_encrypt_key {
$in->ask_from_(
{
- title => N("Filesystem encryption key"),
+ title => N("Filesystem encryption key"),
messages => N("Choose your filesystem encryption key"),
- callbacks => {
+ callbacks => {
complete => sub {
length $encrypt_key < 6 and $in->ask_warn(N("Warning"), N("This encryption key is too simple (must be at least %d characters long)", 6)), return 1,0;
$encrypt_key eq $encrypt_key2 or $in->ask_warn(N("Error"), [ N("The encryption keys do not match"), N("Please try again") ]), return 1,1;
@@ -1391,7 +1506,7 @@ sub tell_wm_and_reboot() {
if (!$wm) {
system('reboot');
- } else {
+ } else {
any::ask_window_manager_to_logout_then_do($wm, $pid, 'reboot');
}
}
diff --git a/perl-install/fs/any.pm b/perl-install/fs/any.pm
index 35be4a1c0..65ca02403 100644
--- a/perl-install/fs/any.pm
+++ b/perl-install/fs/any.pm
@@ -1,4 +1,4 @@
-package fs::any; # $Id: any.pm 240142 2008-03-20 01:18:10Z blino $
+package fs::any; # $Id: any.pm 269745 2010-06-02 11:21:42Z pterjan $
use diagnostics;
use strict;
@@ -97,11 +97,8 @@ sub prepare_minimal_root {
eval { fs::mount::mount('none', "$::prefix/sys", 'sysfs') };
eval { fs::mount::usbfs($::prefix) };
- #- needed by lilo
- if (-d '/dev/mapper' && !$::local_install) {
- my @vgs = map { $_->{VG_name} } @{$all_hds->{lvms}};
- -e "/dev/$_" and cp_af("/dev/$_", "$::prefix/dev") foreach 'mapper', @vgs;
- }
+ # copy all needed devices, for bootloader install and mkinitrd
+ cp_af("/dev", "$::prefix");
}
sub getAvailableSpace {
diff --git a/perl-install/fs/dmcrypt.pm b/perl-install/fs/dmcrypt.pm
index e2d67b37a..0b9c58337 100644
--- a/perl-install/fs/dmcrypt.pm
+++ b/perl-install/fs/dmcrypt.pm
@@ -16,10 +16,8 @@ sub _crypttab() { "$::prefix/etc/crypttab" }
sub init() {
whereis_binary('cryptsetup') or die "cryptsetup not installed";
- eval { modules::load('dm-crypt', 'cbc', 'sha256_generic', arch() =~ /i.86/ ? 'aes-i586' : 'aes') };
+ eval { modules::load('dm-crypt', 'cbc', 'sha256_generic', if_(arch() =~ /i.86/, 'aes-i586'), if_( arch() =~ /x86_64/, 'aes-x86_64'), 'aes_generic') };
devices::init_device_mapper();
- if ($::isInstall) {
- }
1;
}
my $initialized;
@@ -80,6 +78,7 @@ sub open_part {
_run_or_die('luksOpen', devices::make($part->{device}),
$part->{dm_name}, '--key-file', $_[0]);
});
+ run_program::run('udevadm', 'settle') unless $::isInstall;
my $active_dmcrypt = _parse_dmsetup_table($part->{dm_name},
run_program::get_stdout('dmsetup', 'table', $part->{dm_name}));
@@ -110,8 +109,11 @@ sub get_existing {
sub _get_existing_one {
my ($fstab, $active_dmcrypt) = @_;
+ my $p = fs::wild_device::to_subpart("/dev/mapper/$active_dmcrypt->{name}");
+
my $part = { device => "mapper/$active_dmcrypt->{name}", size => $active_dmcrypt->{size},
- options => 'noatime', dmcrypt_name => $active_dmcrypt->{name} };
+ options => 'noatime', dmcrypt_name => $active_dmcrypt->{name},
+ major => $p->{major}, minor => $p->{minor} };
if (my $raw_part = find { fs::get::is_same_hd($active_dmcrypt, $_) } @$fstab) {
$part->{rootDevice} = $raw_part->{device};
@@ -126,7 +128,7 @@ sub _get_existing_one {
}
fs::type::set_isFormatted($part, to_bool($part->{fs_type}));
- $part->{fs_type} or fs::type::set_fs_type($part, 'ext3');
+ $part->{fs_type} or fs::type::set_fs_type($part, defaultFS());
log::l("dmcrypt: found $part->{device} type $part->{fs_type} with rootDevice $part->{rootDevice}");
@@ -146,7 +148,7 @@ sub _parse_dmsetup_table {
}
sub active_dm() {
- run_program::run('udevadm', 'settle');
+ run_program::run('udevadm', 'settle') unless $::isInstall;
map {
my $name = s/(.*?):\s*// && $1;
diff --git a/perl-install/fs/dmraid.pm b/perl-install/fs/dmraid.pm
index 319e48aa5..a744f01af 100644
--- a/perl-install/fs/dmraid.pm
+++ b/perl-install/fs/dmraid.pm
@@ -1,4 +1,4 @@
-package fs::dmraid; # $Id: dmraid.pm 247256 2008-10-01 13:07:51Z pixel $
+package fs::dmraid; # $Id: dmraid.pm 265309 2010-01-27 00:28:23Z pterjan $
use diagnostics;
use strict;
@@ -40,10 +40,26 @@ sub check {
}
sub _raid_devices_raw() {
+ # get the real vg names, needed for ddf1, and safer than begins_with for raid10
+ log::l("_raid_devices_raw");
+ my %vgs;
+ my %pv2vg = map {
+ log::l("got: $_");
+ my %l; @l{qw(name size stride level status subsets devs spares)} = split(':');
+ $vgs{$l{name}} = 1 if defined $l{spares};
+ if(/freeing device "(.*)", path "(.*)"/ && defined $vgs{$1}) {
+ log::l("$2 => $1");
+ { $2 => $1 };
+ }
+ } call_dmraid('-d', '-s', '-c', '-c');
map {
chomp;
log::l("got: $_");
my %l; @l{qw(pv format vg level status size)} = split(':');
+ if(defined $l{size} && defined $l{vg} && defined $pv2vg{$l{pv}} && !defined $vgs{$l{vg}}) {
+ log::l("using $pv2vg{$l{pv}} instead of $l{vg}");
+ $l{vg} = $pv2vg{$l{pv}};
+ }
if_(defined $l{size}, \%l);
} call_dmraid('-r', '-c', '-c');
}
diff --git a/perl-install/fs/format.pm b/perl-install/fs/format.pm
index fcb40dd78..9d328964b 100644
--- a/perl-install/fs/format.pm
+++ b/perl-install/fs/format.pm
@@ -1,4 +1,4 @@
-package fs::format; # $Id: format.pm 245954 2008-09-18 14:18:46Z pixel $
+package fs::format; # $Id: format.pm 268842 2010-05-17 06:54:44Z pterjan $
use diagnostics;
use strict;
@@ -13,7 +13,7 @@ use log;
my %cmds = (
ext2 => [ 'e2fsprogs', 'mkfs.ext2', '-F' ],
ext3 => [ 'e2fsprogs', 'mkfs.ext3', '-F' ],
- ext4dev => [ 'e2fsprogs', 'mkfs.ext3', '-F', '-I', '256' ], # FIXME: enable more options once we've better mkfs support
+ ext4 => [ 'e2fsprogs', 'mkfs.ext4', '-F' ],
reiserfs => [ 'reiserfsprogs', 'mkfs.reiserfs', '-ff' ],
reiser4 => [ 'reiser4progs', 'mkfs.reiser4', '-f', '-y' ],
xfs => [ 'xfsprogs', 'mkfs.xfs', '-f', '-q' ],
@@ -24,19 +24,46 @@ my %cmds = (
swap => [ 'util-linux-ng', 'mkswap' ],
ntfs => [ 'ntfsprogs', 'mkntfs', '--fast' ],
'ntfs-3g' => [ 'ntfsprogs', 'mkntfs', '--fast' ],
+ btrfs => [ 'btrfs-progs', 'mkfs.btrfs' ],
+ nilfs2 => [ 'nilfs-utils', 'mkfs.nilfs2' ],
);
my %LABELs = ( #- option, length, handled_by_mount
ext2 => [ '-L', 16, 1 ],
ext3 => [ '-L', 16, 1 ],
- ext4dev => [ '-L', 16, 1 ],
+ ext4 => [ '-L', 16, 1 ],
reiserfs => [ '-l', 16, 1 ],
+ reiser4 => [ '-L', 16, 1 ],
xfs => [ '-L', 12, 1 ],
jfs => [ '-L', 16, 1 ],
hfs => [ '-l', 27, 0 ],
dos => [ '-n', 11, 0 ],
vfat => [ '-n', 11, 0 ],
swap => [ '-L', 15, 1 ],
+ ntfs => [ '-L', 128, 0 ],
+ 'ntfs-3g' => [ '-L', 128, 0 ],
+ btrfs => [ '-L', 256, 1 ],
+ nilfs2 => [ '-L', 16, 1],
+);
+
+my %edit_LABEL = ( # package, command, option
+# If option is defined, run <command> <option> <label> <device>
+# If no option, run <command> <device> <label>
+ ext2 => [ 'e2fsprogs', 'tune2fs', '-L' ],
+ ext3 => [ 'e2fsprogs', 'tune2fs', '-L' ],
+ ext4 => [ 'e2fsprogs', 'tune2fs', '-L' ],
+ reiserfs => [ 'reiserfsprogs', 'reiserfstune', '-l' ],
+# reiser4
+ xfs => [ 'xfsprogs', 'xfs_admin', '-L' ],
+ jfs => [ 'jfsutils', 'jfs_tune', '-L' ],
+# hfs
+ dos => [ 'mtools', 'mlabel', '-i' ],
+ vfat => [ 'mtools', 'mlabel', '-i' ],
+# swap => [ 'util-linux-ng', 'mkswap' ],
+ ntfs => [ 'ntfsprogs', 'ntfslabel' ],
+ 'ntfs-3g' => [ 'ntfsprogs', 'ntfslabel' ],
+# btrfs
+# nilfs2
);
sub package_needed_for_partition_type {
@@ -50,13 +77,25 @@ sub known_type {
to_bool($cmds{$part->{fs_type}});
}
-sub check_package_is_installed {
+sub check_package_is_installed_format {
my ($do_pkgs, $fs_type) = @_;
my ($pkg, $binary) = @{$cmds{$fs_type} || return};
whereis_binary($binary) || $do_pkgs->ensure_binary_is_installed($pkg, $binary); #- ensure_binary_is_installed checks binary chrooted, whereas we run the binary non-chrooted (pb for Mandriva One)
}
+sub check_package_is_installed_label {
+ my ($do_pkgs, $fs_type) = @_;
+
+ my ($pkg, $binary) = @{$edit_LABEL{$fs_type} || return};
+ whereis_binary($binary) || $do_pkgs->ensure_binary_is_installed($pkg, $binary); #- ensure_binary_is_installed checks binary chrooted, whereas we run the binary non-chrooted (pb for Mandriva One)
+}
+
+sub canEditLabel {
+ my ($part) = @_;
+ to_bool($edit_LABEL{$part->{fs_type}});
+}
+
sub part {
my ($all_hds, $part, $wait_message) = @_;
if (isRAID($part)) {
@@ -72,6 +111,30 @@ sub part {
}
}
+sub write_label {
+ my ($part) = @_;
+
+ $part->{device_LABEL_changed} or return;
+ maybeFormatted($part) or return;
+
+ if ($part->{encrypt_key}) {
+ fs::mount::set_loop($part);
+ }
+
+ my $dev = $part->{real_device} || $part->{device};
+ my ($_pkg, $cmd, @first_options) = @{$edit_LABEL{$part->{fs_type}} || die N("I do not know how to set label on %s with type %s", $part->{device}, $part->{fs_type})};
+ my @args;
+ if ($cmd eq 'mlabel') {
+ @args = ($cmd, @first_options, devices::make($dev), '::' . $part->{device_LABEL});
+ } elsif (defined $first_options[0]) {
+ @args = ($cmd, @first_options, $part->{device_LABEL}, devices::make($dev));
+ } else {
+ @args = ($cmd, devices::make($dev), $part->{device_LABEL});
+ }
+ run_program::raw({ timeout => 'never' }, @args) or die N("setting label on %s failed, is it formatted?", $dev);
+ delete $part->{device_LABEL_changed};
+}
+
sub part_raw {
my ($part, $wait_message) = @_;
@@ -88,7 +151,7 @@ sub part_raw {
my $fs_type = $part->{fs_type};
- if (member($fs_type, qw(ext2 ext3 ext4dev))) {
+ if (member($fs_type, qw(ext2 ext3 ext4))) {
push @options, "-m", "0" if $part->{mntpoint} =~ m|^/home|;
} elsif (isDos($part)) {
$fs_type = 'dos';
@@ -96,40 +159,41 @@ sub part_raw {
push @options, '-l', "Untitled";
} elsif (isAppleBootstrap($part)) {
push @options, '-l', 'bootstrap';
- } elsif (member($fs_type, 'swap', 'ext2', 'ext3')) {
+ }
+
+ # Preserve UUID
+ if (member($fs_type, 'swap', 'ext2', 'ext3', 'ext4')) {
push @options, '-U', $part->{device_UUID} if $part->{device_UUID};
+ } elsif ($fs_type eq 'reiserfs') {
+ push @options, '-u', $part->{device_UUID} if $part->{device_UUID};
}
if ($part->{device_LABEL}) {
- if ($LABELs{$fs_type}) {
- my ($option, $length, $handled_by_mount) = @{$LABELs{$fs_type}};
- if (length $part->{device_LABEL} > $length) {
- my $short = substr($part->{device_LABEL}, 0, $length);
- log::l("shortening LABEL $part->{device_LABEL} to $short");
- $part->{device_LABEL} = $short;
- }
- delete $part->{prefer_device_LABEL}
- if !$handled_by_mount || $part->{mntpoint} eq '/' && !member($fs_type, qw(ext2 ext3 ext4dev));
-
- push @options, $option, $part->{device_LABEL};
- } else {
- log::l("dropping LABEL=$part->{device_LABEL} since we don't know how to set labels for fs_type $part->{fs_type}");
- delete $part->{device_LABEL};
- delete $part->{prefer_device_LABEL};
- }
+ push @options, @{$LABELs{$fs_type}}[0], $part->{device_LABEL};
}
my ($_pkg, $cmd, @first_options) = @{$cmds{$fs_type} || die N("I do not know how to format %s in type %s", $part->{device}, $part->{fs_type})};
my @args = ($cmd, @first_options, @options, devices::make($dev));
- if ($cmd eq 'mkfs.ext3' && $wait_message) {
+ if ($cmd =~ /^mkfs.ext[34]$/ && $wait_message) {
mkfs_ext3($wait_message, @args) or die N("%s formatting of %s failed", $fs_type, $dev);
} else {
run_program::raw({ timeout => 'never' }, @args) or die N("%s formatting of %s failed", $fs_type, $dev);
}
- if (member($fs_type, qw(ext3 ext4dev))) {
+ delete $part->{device_LABEL_changed};
+
+ # Preserve UUID on fs where we couldn't enforce it while formatting
+ if ($fs_type eq 'jfs') {
+ run_program::raw('jfs_tune', '-U', devices::make($dev));
+ } elsif ($fs_type eq 'xfs') {
+ run_program::raw('xfs_admin', '-U', devices::make($dev));
+ } elsif ($fs_type eq 'btrfs') {
+ #FIXME
+ }
+
+ if (member($fs_type, qw(ext3 ext4))) {
disable_forced_fsck($dev);
}
@@ -166,6 +230,28 @@ sub disable_forced_fsck {
run_program::run("tune2fs", "-c0", "-i0", devices::make($dev));
}
+sub clean_label {
+ my ($part) = @_;
+ if ($part->{device_LABEL}) {
+ my $fs_type = $part->{fs_type};
+ if ($LABELs{$fs_type}) {
+ my ($option, $length, $handled_by_mount) = @{$LABELs{$fs_type}};
+ if (length $part->{device_LABEL} > $length) {
+ my $short = substr($part->{device_LABEL}, 0, $length);
+ log::l("shortening LABEL $part->{device_LABEL} to $short");
+ $part->{device_LABEL} = $short;
+ }
+ delete $part->{prefer_device_LABEL}
+ if !$handled_by_mount || $part->{mntpoint} eq '/' && !member($fs_type, qw(ext2 ext3 ext4));
+ } else {
+ log::l("dropping LABEL=$part->{device_LABEL} since we don't know how to set labels for fs_type $fs_type");
+ delete $part->{device_LABEL};
+ delete $part->{prefer_device_LABEL};
+ delete $part->{device_LABEL_changed};
+ }
+ }
+}
+
sub formatMount_part {
my ($part, $all_hds, $fstab, $wait_message) = @_;
@@ -175,12 +261,17 @@ sub formatMount_part {
if (my $p = fs::get::up_mount_point($part->{mntpoint}, $fstab)) {
formatMount_part($p, $all_hds, $fstab, $wait_message) if !fs::type::carry_root_loopback($part);
}
+
+ clean_label($part);
+
if ($part->{toFormat}) {
fs::format::part($all_hds, $part, $wait_message);
+ } else {
+ fs::format::write_label($part);
}
#- setting user_xattr on /home (or "/" if no /home)
- if (!$part->{isMounted} && member($part->{fs_type}, qw(ext3 ext4dev))
+ if (!$part->{isMounted} && member($part->{fs_type}, qw(ext2 ext3 ext4))
&& ($part->{mntpoint} eq '/home' ||
!fs::get::has_mntpoint('/home', $all_hds) && $part->{mntpoint} eq '/')) {
run_program::run('tune2fs', '-o', 'user_xattr', devices::make($part->{real_device} || $part->{device}));
@@ -191,7 +282,7 @@ sub formatMount_part {
sub formatMount_all {
my ($all_hds, $fstab, $wait_message) = @_;
- formatMount_part($_, $all_hds, $fstab, $wait_message)
+ formatMount_part($_, $all_hds, $fstab, $wait_message)
foreach sort { isLoopback($a) ? 1 : isSwap($a) ? -1 : 0 } grep { $_->{mntpoint} } @$fstab;
#- ensure the link is there
diff --git a/perl-install/fs/mount.pm b/perl-install/fs/mount.pm
index 80baee577..3c0696b75 100644
--- a/perl-install/fs/mount.pm
+++ b/perl-install/fs/mount.pm
@@ -1,4 +1,4 @@
-package fs::mount; # $Id: mount.pm 250965 2009-01-08 08:17:26Z pixel $
+package fs::mount; # $Id: mount.pm 267516 2010-04-12 16:40:47Z pterjan $
use diagnostics;
use strict;
@@ -35,7 +35,7 @@ sub mount {
$fs or log::l("not mounting $dev partition"), return;
{
- my @fs_modules = qw(ext3 ext4dev hfs jfs nfs ntfs romfs reiserfs ufs xfs vfat);
+ my @fs_modules = qw(btrfs ext3 ext4 hfs jfs nilfs2 nfs ntfs romfs reiserfs ufs xfs vfat);
my @types = (qw(ext2 proc sysfs usbfs usbdevfs iso9660 devfs devpts auto ntfs-3g), @fs_modules);
push @types, 'smb', 'cifs', 'davfs2' if !$::isInstall;
@@ -72,6 +72,12 @@ sub mount {
fsck_jfs($dev, $o_wait_message);
} elsif ($fs eq 'ext2' && !$b_rdonly) {
fsck_ext2($dev, $o_wait_message);
+ } elsif ($fs eq 'davfs2') {
+ require fs::remote::davfs;
+ # We have to store credentials in davfs2 secret file before mounting
+ fs::remote::davfs::mountpoint_credentials_save($where, \@mount_opt);
+ # username and password options should be handled by /etc/davfs2/secrets file
+ @mount_opt = grep { !/^(username|password)=/ } @mount_opt;
}
push @mount_opt, 'ro' if $b_rdonly;
@@ -172,7 +178,7 @@ sub part {
}
mount($dev, $mntpoint, $fs_type, $b_rdonly, $options, $o_wait_message);
- if ($options =~ /usrquota|grpquota/ && member($part->{fs_type}, qw(ext3 ext4dev))) {
+ if ($options =~ /usrquota|grpquota/ && member($part->{fs_type}, qw(ext3 ext4))) {
if (! find { -e "$mntpoint/$_" } qw(aquota.user aquota.group quota.user quota.group)) {
#- quotacheck will create aquota.user and/or aquota.group,
#- needed for quotas on ext3/ext4.
@@ -216,7 +222,7 @@ sub umount_all {
log::l("unmounting all filesystems");
foreach (sort { $b->{mntpoint} cmp $a->{mntpoint} }
- grep { $_->{mntpoint} && !$_->{real_mntpoint} } @$fstab) {
+ grep { $_->{mntpoint} && !$_->{real_mntpoint} || isSwap($_) } @$fstab) {
umount_part($_);
}
}
diff --git a/perl-install/fs/mount_options.pm b/perl-install/fs/mount_options.pm
index 58c2b3d1b..8b8cc0bff 100644
--- a/perl-install/fs/mount_options.pm
+++ b/perl-install/fs/mount_options.pm
@@ -1,4 +1,4 @@
-package fs::mount_options; # $Id: mount_options.pm 250965 2009-01-08 08:17:26Z pixel $
+package fs::mount_options; # $Id: mount_options.pm 268841 2010-05-17 06:52:12Z pterjan $
use diagnostics;
use strict;
@@ -12,7 +12,7 @@ sub list() {
my %non_defaults = (
sync => 'async', noatime => 'atime', noauto => 'auto', ro => 'rw',
user => 'nouser', nodev => 'dev', noexec => 'exec', nosuid => 'suid',
- user_xattr => 'nouser_xattr',
+ user_xattr => 'nouser_xattr', acl => 'noacl',
);
my @user_implies = qw(noexec nodev nosuid);
\%non_defaults, \@user_implies;
@@ -32,10 +32,9 @@ sub unpack {
nfs => [ qw(rsize=8192 wsize=8192) ],
cifs => [ qw(username= password=) ],
davfs2 => [ qw(username= password= uid= gid=) ],
- ext4dev => [ qw(extents) ],
reiserfs => [ 'notail' ],
);
- push @{$per_fs{$_}}, 'usrquota', 'grpquota' foreach 'ext2', 'ext3', 'ext4dev', 'xfs';
+ push @{$per_fs{$_}}, 'usrquota', 'grpquota' foreach 'ext2', 'ext3', 'ext4', 'xfs';
while (my ($fs, $l) = each %per_fs) {
$part->{fs_type} eq $fs || $part->{fs_type} eq 'auto' && member($fs, @auto_fs) or next;
@@ -43,7 +42,6 @@ sub unpack {
}
$non_defaults->{relatime} = 1 if isTrueLocalFS($part) || $part->{fs_type} eq 'ntfs-3g';
- $non_defaults->{encrypted} = 1;
my $defaults = { reverse %$non_defaults };
my %options = map { $_ => '' } keys %$non_defaults;
@@ -111,8 +109,7 @@ sub pack {
# update me on each util-linux new release:
sub help() {
(
-
- 'encrypted' => N("Use an encrypted file system"),
+ 'acl' => N("Enable Posix Access Control Lists"),
'flush' => N("Flush write cache on file close"),
@@ -226,16 +223,13 @@ sub set_default {
}) if $part->{is_removable};
put_in_hash($options, {
- 'umask=0' => $opts{security} <= 3,
+ 'umask=0' => $opts{security} <= 1,
'iocharset=' => $opts{iocharset}, 'codepage=' => $opts{codepage},
});
}
- if ($part->{fs_type} eq 'ext4dev') {
- put_in_hash($options, { extents => 1 });
- }
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,
+ 'umask=0' => $opts{security} < 1, 'umask=0022' => $opts{security} < 2,
});
}
if (fs::type::can_be_this_fs_type($part, 'iso9660')) {
@@ -245,10 +239,8 @@ sub set_default {
$options->{notail} = 1;
$options->{user_xattr} = 1;
}
- if ($part->{fs_type} eq 'ext3') {
- $options->{user_xattr} = 1;
- put_in_hash($options, { acl => 1 }) ;
-
+ if (member($part->{fs_type}, qw(ext2 ext3 ext4))) {
+ $options->{acl} = 1;
}
if (isLoopback($part) && !isSwap($part)) { #- no need for loop option for swap files
$options->{loop} = 1;
diff --git a/perl-install/fs/mount_point.pm b/perl-install/fs/mount_point.pm
index be1c51c72..5854d4ebe 100644
--- a/perl-install/fs/mount_point.pm
+++ b/perl-install/fs/mount_point.pm
@@ -1,4 +1,4 @@
-package fs::mount_point; # $Id: mount_point.pm 243679 2008-07-29 11:55:58Z tv $
+package fs::mount_point; # $Id: mount_point.pm 269270 2010-05-24 09:55:20Z pterjan $
use diagnostics;
use strict;
@@ -15,7 +15,7 @@ sub guess_mount_point {
'/boot' => 'vmlinuz',
'/tmp' => '.X11-unix',
'/usr' => 'src',
- '/var' => 'catman',
+ '/var' => 'spool',
);
my $handle = any::inspect($part, $prefix) or return;
@@ -47,15 +47,15 @@ sub suggest_mount_points {
sub suggest_mount_points_always {
my ($fstab) = @_;
- my @win = grep { isFat_or_NTFS($_) && maybeFormatted($_) && !$_->{is_removable} && $_->{pt_type} != 0x12 } @$fstab;
+ my @win = grep { isFat_or_NTFS($_) && !$_->{isMounted} && maybeFormatted($_) && !$_->{is_removable} && $_->{pt_type} != 0x12 && !isRecovery($_)} @$fstab;
log::l("win parts: ", join ",", map { $_->{device} } @win) if @win;
if (@win == 1) {
#- Suggest /boot/efi on ia64.
- $win[0]{mntpoint} = arch() =~ /ia64/ ? "/boot/efi" : "/mnt/windows";
+ $win[0]{mntpoint} = arch() =~ /ia64/ ? "/boot/efi" : "/media/windows";
} else {
my %w; foreach (@win) {
my $v = $w{$_->{device_windobe}}++;
- $_->{mntpoint} = $_->{unsafeMntpoint} = "/mnt/win_" . lc($_->{device_windobe}) . ($v ? $v+1 : ''); #- lc cuz of StartOffice(!) cf dadou
+ $_->{mntpoint} = $_->{unsafeMntpoint} = "/media/win_" . lc($_->{device_windobe}) . ($v ? $v+1 : ''); #- lc cuz of StartOffice(!) cf dadou
}
}
@@ -80,8 +80,8 @@ sub validate_mount_points {
$m{$m} and die N("Duplicate mount point %s", $m);
$m{$m} = 1;
- #- in case the type does not correspond, force it to ext3
- fs::type::set_fs_type($_, 'ext3') if !isTrueFS($_) && !isOtherAvailableFS($_);
+ #- in case the type does not correspond, force it to default fs (ext4 currently)
+ fs::type::set_fs_type($_, defaultFS()) if !isTrueFS($_) && !isOtherAvailableFS($_);
}
1;
}
diff --git a/perl-install/fs/partitioning_wizard.pm b/perl-install/fs/partitioning_wizard.pm
index c79ea7717..110759d04 100644
--- a/perl-install/fs/partitioning_wizard.pm
+++ b/perl-install/fs/partitioning_wizard.pm
@@ -1,4 +1,4 @@
-package fs::partitioning_wizard; # $Id: partitioning_wizard.pm 244422 2008-08-27 16:41:21Z tv $
+package fs::partitioning_wizard; # $Id: partitioning_wizard.pm 269969 2010-06-09 13:01:09Z pterjan $
use diagnostics;
use strict;
@@ -11,6 +11,8 @@ use fs::type;
use fs::mount_point;
use partition_table;
use partition_table::raw;
+use partition_table::dos;
+use POSIX qw(ceil);
#- unit of $mb is mega bytes, min and max are in sectors, this
#- function is used to convert back to sectors count the size of
@@ -29,7 +31,7 @@ sub to_Mb {
sub partition_with_diskdrake {
my ($in, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab) = @_;
- my $ok;
+ my $ok;
do {
$ok = 1;
@@ -45,13 +47,14 @@ sub partition_with_diskdrake {
diskdrake::interactive::main($in, $all_hds, $do_force_reload);
}
my @fstab = fs::get::fstab($all_hds);
-
- unless (fs::get::root_(\@fstab)) {
+
+ unless ($root = fs::get::root_(\@fstab)) {
$ok = 0;
$in->ask_okcancel(N("Partitioning"), N("You must have a root partition.
For this, create a partition (or click on an existing one).
Then choose action ``Mount point'' and set it to `/'"), 1) or return;
}
+
if (!any { isSwap($_) } @fstab) {
$ok &&= $in->ask_okcancel('', N("You do not have a swap partition.\n\nContinue anyway?"));
}
@@ -64,22 +67,28 @@ Then choose action ``Mount point'' and set it to `/'"), 1) or return;
}
sub partitionWizardSolutions {
- my ($in, $all_hds, $all_fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab) = @_;
+ my ($in, $all_hds, $all_fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, $target) = @_;
my $hds = $all_hds->{hds};
- my $fstab = [ fs::get::fstab($all_hds) ];
+ my $fstab;
+ my $full_fstab = [ fs::get::fstab($all_hds) ];
+ if ($target) {
+ $hds = [ $target ];
+ $fstab = [ grep { $_->{rootDevice} eq $target->{device} } fs::get::fstab($all_hds) ];
+ } else {
+ $fstab = $full_fstab;
+ }
+
my @wizlog;
my (%solutions);
- my $min_linux = MB(400);
- my $max_linux = MB(2000);
+ my $min_linux = MB(600);
my $min_swap = MB(50);
- my $max_swap = MB(300);
my $min_freewin = MB(100);
# each solution is a [ score, text, function ], where the function retunrs true if succeeded
my @hds_rw = grep { !$_->{readonly} } @$hds;
- my @hds_can_add = grep { $_->can_add } @hds_rw;
+ my @hds_can_add = grep { $_->{type} ne 'hd' || $_->can_add } @hds_rw;
if (fs::get::hds_free_space(@hds_can_add) > $min_linux) {
$solutions{free_space} = [ 30, N("Use free space"), sub { fsedit::auto_allocate($all_hds, $partitions); 1 } ];
} else {
@@ -91,67 +100,82 @@ sub partitionWizardSolutions {
if (my @truefs = grep { isTrueLocalFS($_) } @$fstab) {
#- value twice the ext2 partitions
- $solutions{existing_part} = [ 20 + @truefs + @$fstab, N("Use existing partitions"), sub { fs::mount_point::ask_mount_points($in, $fstab, $all_hds) } ];
+ $solutions{existing_part} = [ 20 + @truefs + @$fstab, N("Use existing partitions"), sub { fs::mount_point::ask_mount_points($in, $full_fstab, $all_hds) } ];
} else {
push @wizlog, N("There is no existing partition to use");
}
- 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} =
- [ -10 - @fats, N("Use the Microsoft Windows® partition for loopback"),
- sub {
- my ($s_root, $s_swap);
- my $part = $in->ask_from_listf('', N("Which partition do you want to use for Linux4Win?"), \&partition_table::description, \@ok_forloopback) or return;
- $max_swap = $min_swap + 1 if $part->{free} - $max_swap < $min_linux;
- $in->ask_from('', N("Choose the sizes"), [
- { label => N("Root partition size in MB: "), val => \$s_root, min => to_Mb($min_linux), max => to_Mb(min($part->{free} - $max_swap, $max_linux)), type => 'range' },
- { label => N("Swap partition size in MB: "), val => \$s_swap, min => to_Mb($min_swap), max => to_Mb($max_swap), type => 'range' },
- ]) or return;
- push @{$part->{loopback}},
- { fs_type => 'ext3', loopback_file => '/lnx4win/linuxsys.img', mntpoint => '/', size => $s_root * 2048, loopback_device => $part, notFormatted => 1 },
- { fs_type => 'swap', loopback_file => '/lnx4win/swapfile', mntpoint => 'swap', size => $s_swap * 2048, loopback_device => $part, notFormatted => 1 };
- fsedit::recompute_loopbacks($all_hds);
- 1;
- } ];
- } else {
- push @wizlog, N("There is no FAT partition to use as loopback (or not enough space left)") .
- (@fats ? "\nFAT partitions:" . join('', map { "\n $_->{device} $_->{free} (" . ($min_linux + $min_swap + $min_freewin) . ")" } @fats) : '');
- }
-
-
if (my @ok_for_resize_fat = grep { isFat_or_NTFS($_) && !fs::get::part2hd($_, $all_hds)->{readonly}
- && fs::type::part2type_name($_) !~ /^Hidden/ } @$fstab) {
- $solutions{resize_fat} =
- [ 20 - @ok_for_resize_fat, N("Use the free space on a Microsoft Windows® partition"),
- sub {
- my $part = $in->ask_from_listf_raw({ messages => N("Which partition do you want to resize?"),
- interactive_help_id => 'resizeFATChoose',
- }, \&partition_table::description, \@ok_for_resize_fat) or return;
- my $hd = fs::get::part2hd($part, $all_hds);
- my $resize_fat = eval {
- my $pkg = $part->{fs_type} eq 'vfat' ? do {
- require resize_fat::main;
- 'resize_fat::main';
- } : do {
- require diskdrake::resize_ntfs;
- 'diskdrake::resize_ntfs';
- };
- $pkg->new($part->{device}, devices::make($part->{device}));
- };
- $@ and die N("The FAT resizer is unable to handle your partition,
-the following error occurred: %s", formatError($@));
- my $min_win = do {
- my $_w = $in->wait_message(N("Resizing"), N("Computing the size of the Microsoft Windows® partition"));
- $resize_fat->min_size;
- };
- #- make sure that even after normalizing the size to cylinder boundaries, the minimun will be saved,
- #- this save at least a cylinder (less than 8Mb).
- $min_win += partition_table::raw::cylinder_size($hd);
-
- $part->{size} > $min_linux + $min_swap + $min_freewin + $min_win or die N("Your Microsoft Windows® partition is too fragmented. Please reboot your computer under Microsoft Windows®, run the ``defrag'' utility, then restart the Mandriva Linux installation.");
- $in->ask_okcancel('', formatAlaTeX(
+ && !isRecovery($_) && $_->{size} > $min_linux + $min_swap + $min_freewin } @$fstab) {
+ @ok_for_resize_fat = map {
+ my $part = $_;
+ my $hd = fs::get::part2hd($part, $all_hds);
+ my $resize_fat = eval {
+ my $pkg = $part->{fs_type} eq 'vfat' ? do {
+ require resize_fat::main;
+ 'resize_fat::main';
+ } : do {
+ require diskdrake::resize_ntfs;
+ 'diskdrake::resize_ntfs';
+ };
+ $pkg->new($part->{device}, devices::make($part->{device}));
+ };
+ if ($@) {
+ log::l("The FAT resizer is unable to handle $part->{device} partition%s", formatError($@));
+ undef $part;
+ }
+ if ($part) {
+ my $min_win = eval {
+ my $_w = $in->wait_message(N("Resizing"), N("Computing the size of the Microsoft Windows® partition"));
+ $resize_fat->min_size + $min_freewin;
+ };
+ if ($@) {
+ log::l("The FAT resizer is unable to get minimal size for $part->{device} partition %s", formatError($@));
+ undef $part;
+ } else {
+ my $min_linux_all = $min_linux + $min_swap;
+ #- make sure that even after normalizing the size to cylinder boundaries, the minimun will be saved,
+ #- this save at least a cylinder (less than 8Mb).
+ $min_win += partition_table::raw::cylinder_size($hd);
+
+ if ($part->{size} <= $min_linux_all + $min_win) {
+# die N("Your Microsoft Windows® partition is too fragmented. Please reboot your computer under Microsoft Windows®, run the ``defrag'' utility, then restart the Mandriva Linux installation.");
+ undef $part;
+ } else {
+ $part->{resize_fat} = $resize_fat;
+ $part->{min_win} = $min_win;
+ $part->{min_linux} = $min_linux_all;
+ #- try to keep at least 1GB free for Windows
+ #- try to use from 6GB to 10% free space for Linux
+ my $suggested_size = max(
+ $part->{min_win} + 1 * MB(1024),
+ min(
+ $part->{size} - int(0.1 * ($part->{size} - $part->{min_win})),
+ $part->{size} - 6 * MB(1024),
+ ),
+ );
+ $part->{req_size} = max(min($suggested_size, $part->{size} - $part->{min_linux}), $part->{min_win});
+ }
+ }
+ }
+ $part || ();
+ } @ok_for_resize_fat;
+ if (@ok_for_resize_fat) {
+ $solutions{resize_fat} =
+ [ 20 - @ok_for_resize_fat, N("Use the free space on a Microsoft Windows® partition"),
+ sub {
+ my $part;
+ if (!$in->isa('interactive::gtk')) {
+ $part = $in->ask_from_listf_raw({ messages => N("Which partition do you want to resize?"),
+ interactive_help_id => 'resizeFATChoose',
+ }, \&partition_table::description, \@ok_for_resize_fat) or return;
+ $part->{size} > $part->{min_linux} + $part->{min_win} or die N("Your Microsoft Windows® partition is too fragmented. Please reboot your computer under Microsoft Windows®, run the ``defrag'' utility, then restart the Mandriva Linux installation.");
+ } else {
+ $part = top(grep { $_->{req_size} } @ok_for_resize_fat);
+ }
+ my $resize_fat = $part->{resize_fat};
+ my $hd = fs::get::part2hd($part, $all_hds);
+ $in->ask_okcancel('', formatAlaTeX(
#-PO: keep the double empty lines between sections, this is formatted a la LaTeX
N("WARNING!
@@ -164,49 +188,58 @@ Be careful: this operation is dangerous. If you have not already done so, you fi
When sure, press %s.", N("Next")))) or return;
- my $mb_size = to_Mb($part->{size});
- $in->ask_from(N("Partitionning"), N("Which size do you want to keep for Microsoft Windows® on partition %s?", partition_table::description($part)), [
- { label => N("Size"), val => \$mb_size, min => to_Mb($min_win), max => to_Mb($part->{size} - $min_linux - $min_swap), type => 'range' },
- ]) or return;
-
- my $oldsize = $part->{size};
- $part->{size} = from_Mb($mb_size, $min_win, $part->{size});
-
- $hd->adjustEnd($part);
-
- eval {
- my $_w = $in->wait_message(N("Resizing"), N("Resizing Microsoft Windows® partition"));
- $resize_fat->resize($part->{size});
- };
- if (my $err = $@) {
- $part->{size} = $oldsize;
- die N("FAT resizing failed: %s", formatError($err));
- }
-
- $in->ask_warn('', N("To ensure data integrity after resizing the partition(s),
+ my $oldsize = $part->{size};
+ if (!$in->isa('interactive::gtk')) {
+ my $mb_size = to_Mb($part->{req_size});
+ my $max_win = $part->{size} - $part->{min_linux};
+ $in->ask_from(N("Partitionning"), N("Which size do you want to keep for Microsoft Windows® on partition %s?", partition_table::description($part)), [
+ { label => N("Size"), val => \$mb_size, min => to_Mb($part->{min_win}), max => to_Mb($max_win), type => 'range' },
+ ]) or return;
+ $part->{req_size} = from_Mb($mb_size, $part->{min_win}, $part->{max_win});
+ }
+ $part->{size} = $part->{req_size};
+
+ $hd->adjustEnd($part);
+
+ eval {
+ my $_w = $in->wait_message(N("Resizing"), N("Resizing Microsoft Windows® partition"));
+ $resize_fat->resize($part->{size});
+ };
+ if (my $err = $@) {
+ $part->{size} = $oldsize;
+ die N("FAT resizing failed: %s", formatError($err));
+ }
+
+ $in->ask_warn('', N("To ensure data integrity after resizing the partition(s),
filesystem checks will be run on your next boot into Microsoft Windows®")) if $part->{fs_type} ne 'vfat';
- 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);
+ 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);
- fsedit::auto_allocate($all_hds, $partitions);
- 1;
- } ];
+ fsedit::auto_allocate($all_hds, $partitions);
+ 1;
+ }, \@ok_for_resize_fat ];
+ }
} else {
push @wizlog, N("There is no FAT partition to resize (or not enough space left)");
}
if (@$fstab && @hds_rw) {
$solutions{wipe_drive} =
- [ 10, fsedit::is_one_big_fat_or_NT($hds) ? N("Remove Microsoft Windows®") : N("Erase and use entire disk"),
+ [ 10, fsedit::is_one_big_fat_or_NT($hds) ? N("Remove Microsoft Windows®") : N("Erase and use entire disk"),
sub {
- my $hd = $in->ask_from_listf_raw({ messages => N("You have more than one hard drive, which one do you install linux on?"),
- title => N("Partitioning"),
- interactive_help_id => 'takeOverHdChoose',
- },
- \&partition_table::description, \@hds_rw) or return;
+ my $hd;
+ if (!$in->isa('interactive::gtk')) {
+ $hd = $in->ask_from_listf_raw({ messages => N("You have more than one hard drive, which one do you install linux on?"),
+ title => N("Partitioning"),
+ interactive_help_id => 'takeOverHdChoose',
+ },
+ \&partition_table::description, \@hds_rw) or return;
+ } else {
+ $hd = $target;
+ }
$in->ask_okcancel_({ messages => N("ALL existing partitions and their data will be lost on drive %s", partition_table::description($hd)),
title => N("Partitioning"),
interactive_help_id => 'takeOverHdConfirm' }) or return;
@@ -223,7 +256,7 @@ filesystem checks will be run on your next boot into Microsoft Windows®")) if $
}
$solutions{fdisk} =
- [ -10, N("Use fdisk"), sub {
+ [ -10, N("Use fdisk"), sub {
$in->enter_console;
foreach (@$hds) {
print "\n" x 10, N("You can now partition %s.
@@ -234,7 +267,7 @@ When you are done, do not forget to save using `w'", partition_table::descriptio
$pid = fork() or exec "pdisk", devices::make($_->{device});
} else {
$pid = fork() or exec "fdisk", devices::make($_->{device});
- }
+ }
waitpid($pid, 0);
}
$in->leave_console;
@@ -250,34 +283,308 @@ sub warn_reboot_needed {
$in->ask_warn(N("Partitioning"), N("You need to reboot for the partition table modifications to take place"));
}
-sub main {
- my ($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, $b_nodiskdrake) = @_;
+sub create_display_box {
+ my ($kind, $resize, $fill_empty, $button) = @_;
+ my @parts = fs::get::hds_fstab_and_holes($kind->{val});
+
+ my $totalsectors = $kind->{val}{totalsectors};
+
+ my $width = 540;
+ my $minwidth = 40;
+
+ my $display_box = ugtk2::gtkset_size_request(Gtk2::HBox->new(0,0), -1, 26);
+
+ my $sep_count = @parts - 1;
+ #- ratio used to compute initial partition pixel width (each partition should be > min_width)
+ #- though, the pixel/sectors ratio can not be the same for all the partitions
+ my $initial_ratio = $totalsectors ? ($width - @parts * $minwidth - $sep_count) / $totalsectors : 1;
+
+ my $vbox = Gtk2::VBox->new;
+
+ my $part_sep;
+ my $desc;
+
+ my $last = $resize && $resize->[-1];
+
+ foreach my $entry (@parts) {
+ my $part_info = Gtk2::Label->new($entry->{device_LABEL});
+ my @colorized_fs_types = qw(ext2 ext3 ext4 xfs swap vfat ntfs ntfs-3g);
+ my $part_widget = Gtk2::EventBox->new;
+ $entry->{width} = int($entry->{size} * $initial_ratio) + $minwidth;
+ if ($last && $last->{device} eq $entry->{device}) {
+ #- entry is the last resizable partition
+
+ my $ratio;
+ my $update_ratio = sub { $ratio = $entry->{width} / $entry->{size} };
+ $update_ratio->();
+
+ $part_widget->set_name("PART_vfat");
+ $part_info->set_size_request(ceil($ratio * $entry->{min_win}), 0);
+
+ my $mdv_widget = gtkadd(gtkset_name(Gtk2::EventBox->new, "PART_new"),
+ gtkset_size_request(gtknew("Image", file => "small-logo"),
+ $ratio * MB(600), 0));
+
+ my $hpane = Gtk2::HPaned->new;
+ $hpane->add1($part_widget);
+ $hpane->child1_shrink(0);
+ $hpane->add2($mdv_widget);
+ $hpane->child2_shrink(0);
+ $hpane->set_position(ceil($ratio * $entry->{req_size}));
+ ugtk2::gtkset_size_request($hpane, $entry->{width}, 0);
+ ugtk2::gtkpack__($display_box, $hpane);
+
+ my $add_part_size_info = sub {
+ my ($name, $label) = @_;
+ ugtk2::gtkpack__($desc,
+ gtkadd(gtkset_name(Gtk2::EventBox->new, $name),
+ Gtk2::Label->new(" " x 4)),
+ gtkset_size_request(gtkset_alignment($label, 0, 0.5),
+ 150, 20));
+ };
+ $desc = Gtk2::HBox->new(0,0);
+
+ my $win_size_label = Gtk2::Label->new;
+ $add_part_size_info->("PART_vfat", $win_size_label);
+
+ my $mdv_size_label = Gtk2::Label->new;
+ $add_part_size_info->("PART_new", $mdv_size_label);
+
+ my $update_size_labels = sub {
+ $win_size_label->set_label(" Windows (" . formatXiB($entry->{req_size}, 512) . ")");
+ $mdv_size_label->set_label(" Mandriva (" . formatXiB($entry->{size} - $entry->{req_size}, 512) . ")");
+ 0;
+ };
+ my $update_req_size = sub {
+ $entry->{req_size} = int($hpane->get_position / $ratio);
+ $update_size_labels->();
+ };
+ my $button_activate = sub {
+ $button->activate;
+ 0;
+ };
+ $hpane->signal_connect('size-allocate' => sub {
+ my (undef, $alloc) = @_;
+ $entry->{width} = $alloc->width;
+ $update_ratio->();
+ 0;
+ });
+ $update_size_labels->();
+ $hpane->signal_connect('motion-notify-event' => $update_req_size);
+ $hpane->signal_connect('move-handle' => $update_req_size);
+ $hpane->signal_connect('button-press-event' => $button_activate);
+ $vbox->signal_connect('button-press-event' => $button_activate);
+ $button->signal_connect('focus-in-event' => sub {
+ $hpane->grab_focus;
+ 0;
+ });
+ } else {
+ if ($fill_empty && isEmpty($entry)) {
+ $part_info = gtknew("Image", file => "small-logo");
+ $part_widget->set_name("PART_new");
+ } else {
+ $part_widget->set_name("PART_" . (isEmpty($entry) ? 'empty' :
+ $entry->{fs_type} && member($entry->{fs_type}, @colorized_fs_types) ? $entry->{fs_type} :
+ 'other'));
+ }
+ $part_widget->set_size_request($entry->{width}, 0);
+ ugtk2::gtkpack($display_box, $part_widget);
+ }
+ $part_widget->add($part_info);
- my %solutions = partitionWizardSolutions($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab);
+ $part_sep = gtkadd(Gtk2::EventBox->new,
+ gtkset_size_request(Gtk2::Label->new("."), 1, 0));
+ gtkpack__($display_box, $part_sep);
+ }
+ $display_box->remove($part_sep) if $part_sep;
+ unless ($resize || $fill_empty) {
+ my @types = (N_("Ext2/3/4"), N_("XFS"), N_("Swap"), arch() =~ /sparc/ ? N_("SunOS") : arch() eq "ppc" ? N_("HFS") : N_("Windows"),
+ N_("Other"), N_("Empty"));
+ my %name2fs_type = ('Ext2/3/4' => 'ext3', 'XFS' => 'xfs', Swap => 'swap', Other => 'other', "Windows" => 'vfat', HFS => 'hfs');
+ $desc = ugtk2::gtkpack(Gtk2::HBox->new,
+ map {
+ my $t = $name2fs_type{$_};
+ my $ev = Gtk2::EventBox->new;
+ my $w = Gtk2::Label->new(translate($_));
+ $ev->add($w);
+ $ev->set_name('PART_' . ($t || 'empty'));
+ $ev;
+ } @types);
+ }
- delete $solutions{diskdrake} if $b_nodiskdrake;
+ $vbox->add($display_box);
+ $vbox->add($desc) if $desc;
- my @solutions = sort { $b->[0] <=> $a->[0] } values %solutions;
+ $vbox;
+}
- my @sol = grep { $_->[0] >= 0 } @solutions;
+sub display_choices {
+ my ($o, $contentbox, $mainw, %solutions) = @_;
+ my @solutions = sort { $solutions{$b}[0] <=> $solutions{$a}[0] } keys %solutions;
+ my @sol = grep { $solutions{$_}[0] >= 0 } @solutions;
- log::l('' . "solutions found: " . join('', map { $_->[1] } @sol) .
- " (all solutions found: " . join('', map { $_->[1] } @solutions) . ")");
+ log::l('' . "solutions found: " . join('', map { $solutions{$_}[1] } @sol) .
+ " (all solutions found: " . join('', map { $solutions{$_}[1] } @solutions) . ")");
@solutions = @sol if @sol > 1;
log::l("solutions: ", int @solutions);
@solutions or $o->ask_warn(N("Partitioning"), N("I can not find any room for installing")), die 'already displayed';
- log::l('HERE: ', join(',', map { $_->[1] } @solutions));
+ log::l('HERE: ', join(',', map { $solutions{$_}[1] } @solutions));
+
+ $contentbox->foreach(sub { $contentbox->remove($_[0]) });
+
+ $mainw->{kind}{display_box} ||= create_display_box($mainw->{kind});
+ ugtk2::gtkpack2__($contentbox, $mainw->{kind}{display_box});
+ ugtk2::gtkpack__($contentbox, gtknew('Label',
+ text => N("The DrakX Partitioning wizard found the following solutions:"),
+ alignment => [0, 0]));
+
+ my $choicesbox = gtknew('VBox');
+ my $oldbutton;
+ my $sep;
+ foreach my $s (@solutions) {
+ my $item;
+ my $vbox = gtknew('VBox');
+ my $button = gtknew('RadioButton', child => $vbox);
+ if ($s eq 'free_space') {
+ $item = create_display_box($mainw->{kind}, undef, 1);
+ } elsif ($s eq 'resize_fat') {
+ $item = create_display_box($mainw->{kind}, $solutions{$s}[3], undef, $button);
+ } elsif ($s eq 'existing_part') {
+ } elsif ($s eq 'wipe_drive') {
+ $item = Gtk2::EventBox->new;
+ my $b2 = gtknew("Image", file => "small-logo");
+ $item->add($b2);
+ $item->set_size_request(540,26);
+ $item->set_name("PART_new");
+ } elsif ($s eq 'diskdrake') {
+ } else {
+ log::l($s);
+ next;
+ }
+ ugtk2::gtkpack($vbox,
+ gtknew('Label',
+ text => $solutions{$s}[1],
+ alignment => [0, 0]));
+ ugtk2::gtkpack($vbox, $item) if defined($item);
+ $button->set_group($oldbutton->get_group) if $oldbutton;
+ $oldbutton = $button;
+ $button->signal_connect('toggled', sub { $mainw->{sol} = $solutions{$s} if $_[0]->get_active });
+ ugtk2::gtkpack2__($choicesbox, $button);
+ $sep = gtknew('HSeparator');
+ ugtk2::gtkpack2__($choicesbox, $sep);
+ }
+ $choicesbox->remove($sep);
+ ugtk2::gtkadd($contentbox, $choicesbox);
+ $mainw->{sol} = $solutions{@solutions[0]};
+}
+
+sub main {
+ my ($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, $b_nodiskdrake) = @_;
+
my $sol;
- $o->ask_from_({
- title => N("Partitioning"),
- interactive_help_id => 'doPartitionDisks',
- },
- [
- { label => N("The DrakX Partitioning wizard found the following solutions:"), title => $::isInstall },
- { val => \$sol, list => \@solutions, format => sub { $_[0][1] }, type => 'list' },
- ]);
+
+ if ($o->isa('interactive::gtk')) {
+ require mygtk2;
+ mygtk2->import(qw(gtknew));
+ require ugtk2;
+ ugtk2->import(qw(:wrappers));
+
+ my $mainw = ugtk2->new(N("Partitioning"), %$o, if__($::main_window, transient => $::main_window));
+ $mainw->{box_allow_grow} = 1;
+
+ mygtk2::set_main_window_size($mainw->{rwindow});
+
+ require diskdrake::hd_gtk;
+ diskdrake::hd_gtk::load_theme();
+
+ my $mainbox = Gtk2::VBox->new;
+
+ my @kinds = map { diskdrake::hd_gtk::hd2kind($_) } sort { $a->{is_removable} <=> $b->{is_removable} } @{$all_hds->{hds} };
+ push @kinds, map { diskdrake::hd_gtk::raid2kind($_) } @{$all_hds->{raids}};
+ push @kinds, map { diskdrake::hd_gtk::lvm2kind($_) } @{$all_hds->{lvms}};
+
+ my $hdchoice = Gtk2::HBox->new;
+
+ my $hdchoicelabel = Gtk2::Label->new(N("Here is the content of your disk drive "));
+
+ my $combobox = Gtk2::ComboBox->new_text;
+ foreach (@kinds) {
+ my $info = $_->{val}{info} || $_->{val}{device};
+ $info =~ s|^(?:.*/)?(.{24}).*|$1|;
+ $info .= " (" . formatXiB($_->{val}{totalsectors}, 512) . ")" if $_->{val}{totalsectors};
+ $combobox->append_text($info);
+ }
+ $combobox->set_active(0);
+
+ ugtk2::gtkpack2__($hdchoice, $hdchoicelabel);
+ $hdchoice->add($combobox);
+
+ ugtk2::gtkpack2__($mainbox, $hdchoice);
+
+ my $contentbox = Gtk2::VBox->new(0, 12);
+
+ my $scroll = Gtk2::ScrolledWindow->new;
+ $scroll->set_policy('never', 'automatic'),
+ my $vp = Gtk2::Viewport->new;
+ $vp->set_shadow_type('none');
+ $vp->add($contentbox);
+ $scroll->add($vp);
+ $mainbox->add($scroll);
+
+ my $kind = @kinds[$combobox->get_active];
+ my %solutions = partitionWizardSolutions($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, diskdrake::hd_gtk::kind2hd($kind));
+ delete $solutions{diskdrake} if $b_nodiskdrake;
+ $mainw->{kind} = $kind;
+ display_choices($o, $contentbox, $mainw, %solutions);
+
+ $combobox->signal_connect("changed", sub {
+ $mainw->{kind} = @kinds[$combobox->get_active];
+ my %solutions = partitionWizardSolutions($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab, diskdrake::hd_gtk::kind2hd($mainw->{kind}));
+ delete $solutions{diskdrake} if $b_nodiskdrake;
+ display_choices($o, $contentbox, $mainw, %solutions);
+ $mainw->{window}->show_all;
+ });
+
+ my @more_buttons = (
+ if_($::isInstall,
+ [ gtknew('Install_Button',
+ text => N("Help"),
+ clicked => sub { interactive::gtk::display_help($o, {interactive_help_id => 'doPartitionDisks' }, $mainw) }),
+ undef, 1 ]),
+ );
+ my $buttons_pack = $mainw->create_okcancel(N("Next"), undef, '', @more_buttons);
+ $mainbox->pack_end($buttons_pack, 0, 0, 0);
+ ugtk2::gtkadd($mainw->{window}, $mainbox);
+ $mainw->{window}->show_all;
+
+ $mainw->main;
+
+ $sol=$mainw->{sol};
+ } else {
+ my %solutions = partitionWizardSolutions($o, $all_hds, $fstab, $manual_fstab, $partitions, $partitioning_flags, $skip_mtab);
+
+ delete $solutions{diskdrake} if $b_nodiskdrake;
+
+ my @solutions = sort { $b->[0] <=> $a->[0] } values %solutions;
+
+ my @sol = grep { $_->[0] >= 0 } @solutions;
+ log::l('' . "solutions found: " . join('', map { $_->[1] } @sol) .
+ " (all solutions found: " . join('', map { $_->[1] } @solutions) . ")");
+ @solutions = @sol if @sol > 1;
+ log::l("solutions: ", int @solutions);
+ @solutions or $o->ask_warn(N("Partitioning"), N("I can not find any room for installing")), die 'already displayed';
+ log::l('HERE: ', join(',', map { $_->[1] } @solutions));
+ $o->ask_from_({
+ title => N("Partitioning"),
+ interactive_help_id => 'doPartitionDisks',
+ },
+ [
+ { label => N("The DrakX Partitioning wizard found the following solutions:"), title => $::isInstall },
+ { val => \$sol, list => \@solutions, format => sub { $_[0][1] }, type => 'list' },
+ ]);
+ }
log::l("partitionWizard calling solution $sol->[1]");
my $ok = eval { $sol->[2]->() };
if (my $err = $@) {
diff --git a/perl-install/fs/type.pm b/perl-install/fs/type.pm
index 0e17bbd00..bb90bdfe1 100644
--- a/perl-install/fs/type.pm
+++ b/perl-install/fs/type.pm
@@ -1,4 +1,4 @@
-package fs::type; # $Id: type.pm 257105 2009-04-27 15:22:01Z pterjan $
+package fs::type; # $Id: type.pm 269283 2010-05-24 15:31:58Z pterjan $
use diagnostics;
use strict;
@@ -9,8 +9,8 @@ use devices;
our @ISA = qw(Exporter);
our @EXPORT = qw(
- isEmpty isExtended isTrueLocalFS isTrueFS isDos isSwap isOtherAvailableFS isRawLVM isRawRAID isRAID isLVM isMountableRW isNonMountable isPartOfLVM isPartOfRAID isPartOfLoopback isLoopback isMounted isBusy isSpecial isApple isAppleBootstrap isWholedisk isFat_or_NTFS
- maybeFormatted set_isFormatted
+ isEmpty isExtended isTrueLocalFS isTrueFS isDos isSwap isOtherAvailableFS isRawLVM isRawRAID isRawLUKS isRAID isLVM isLUKS isMountableRW isNonMountable isPartOfLVM isPartOfRAID isPartOfLoopback isLoopback isMounted isBusy isSpecial isApple isAppleBootstrap isWholedisk isFat_or_NTFS isRecovery
+ maybeFormatted set_isFormatted defaultFS
);
@@ -22,6 +22,7 @@ my (%type_name2pt_type, %type_name2fs_type, %fs_type2pt_type, %pt_type2fs_type,
0x82 => 'swap', 'Linux swap',
0x83 => 'ext2', 'Linux native',
0x83 => 'ext3', 'Journalised FS: ext3',
+ 0x83 => 'ext4', 'Journalised FS: ext4',
0x83 => 'reiserfs', 'Journalised FS: ReiserFS',
if_(arch() =~ /ppc|i.86|ia64|x86_64/,
0x83 => 'xfs', 'Journalised FS: XFS',
@@ -120,8 +121,9 @@ if_(arch() !~ /ppc/,
0x81 => '', 'Minix / old Linux',
if_(!$::isInstall,
0x83 => 'reiser4', 'Journalised FS: Reiser4',
- 0x83 => 'ext4dev', 'Journalised FS: ext4',
+ 0x83 => 'nilfs2', 'NILFS2',
),
+ 0x83 => 'btrfs', 'Btrfs',
0x84 => '', 'OS/2 hidden C: drive',
0x86 => '', 'NTFS volume set (0x86)',
0x87 => '', 'NTFS volume set (0x87)',
@@ -183,7 +185,7 @@ if_(arch() !~ /ppc/,
sub type_names {
my ($expert, $o_hd) = @_;
my @l = @{$type_names{important}};
- push @l, @{$type_names{non_fs_type}};
+ push @l, grep { $_ ne 'Encrypted' } @{$type_names{non_fs_type}};
push @l, sort @{$type_names{other}} if $expert;
if ($o_hd && !$o_hd->use_pt_type) {
warn "$_ => $type_name2fs_type{$_}\n" foreach @l;
@@ -270,19 +272,19 @@ sub fs_type_from_magic {
}
}
-sub call_vol_id {
+sub call_blkid {
my ($part) = @_;
my %h = map {
if_(/(.*?)=(.*)/, $1 => $2);
- } run_program::get_stdout('vol_id', '2>', '/dev/null', devices::make($part->{device}));
+ } run_program::get_stdout('blkid', '2>', '/dev/null', '-o', 'udev', '-p', devices::make($part->{device}));
\%h;
}
sub type_subpart_from_magic {
my ($part) = @_;
- my $ids = call_vol_id($part);
+ my $ids = call_blkid($part);
my $p;
if ($ids->{ID_FS_USAGE} eq 'raid') {
@@ -297,19 +299,21 @@ sub type_subpart_from_magic {
$p = type_name2subpart('Encrypted');
} elsif (my $fs_type = $ids->{ID_FS_TYPE}) {
$fs_type = 'ntfs-3g' if $fs_type eq 'ntfs';
- $p = fs_type2subpart($fs_type) or log::l("unknown filesystem $fs_type returned by vol_id");
+ $p = fs_type2subpart($fs_type) or log::l("unknown filesystem $fs_type returned by blkid");
}
if ($p) {
$part->{fs_type_from_magic} = $p->{fs_type};
$p->{device_LABEL} = $ids->{ID_FS_LABEL} if $ids->{ID_FS_LABEL};
$p->{device_UUID} = $ids->{ID_FS_UUID} if $ids->{ID_FS_UUID};
- log::l("vol_id gave: $p->{fs_type} $p->{device_UUID} $p->{device_LABEL}");
+ log::l("blkid gave: $p->{fs_type} $p->{device_UUID} $p->{device_LABEL}");
}
$p;
}
-sub true_local_fs_types() { qw(ext3 ext2 ext4dev reiserfs reiser4 xfs jfs) }
+sub defaultFS { 'ext4' }
+
+sub true_local_fs_types() { qw(btrfs ext3 ext2 ext4 reiserfs reiser4 xfs jfs) }
sub isEmpty { !$_[0]{fs_type} && $_[0]{pt_type} == 0 }
sub isEfi { arch() =~ /ia64/ && $_[0]{pt_type} == 0xef }
@@ -323,6 +327,14 @@ sub isDos { arch() !~ /^sparc/ && ${{ 1 => 1, 4 => 1, 6 => 1 }}{$_[0]{pt_type}}
sub isFat_or_NTFS { member($_[0]{fs_type}, 'vfat', 'ntfs', 'ntfs-3g') }
sub isApple { $_[0]{pt_type} == 0x401 && defined $_[0]{isDriver} }
sub isAppleBootstrap { $_[0]{pt_type} == 0x401 && defined $_[0]{isBoot} }
+sub isRecovery {
+ isFat_or_NTFS($_[0]) && ($_[0]{type_name} =~ /^Hidden/ ||
+ member($_[0]{device_LABEL} ,
+ # Extracted from /usr/share/hal/fdi/policy/10osvendor/20-storage-methods.fdi
+ # Hopefuly we'll ask to hal/udev someday
+ 'RECOVERY', 'PQSERVICE', 'HP_RECOVERY', 'Recovery Partition', 'DellUtility', 'DellRestore', 'IBM_SERVICE', 'SERVICEV001', 'SERVICEV002')
+ )
+}
sub isTrueFS { isTrueLocalFS($_[0]) || member($_[0]{fs_type}, qw(nfs)) }
sub isTrueLocalFS { member($_[0]{fs_type}, true_local_fs_types()) }
@@ -341,9 +353,10 @@ sub isNonMountable {
sub isPartOfLVM { defined $_[0]{lvm} }
sub isPartOfRAID { defined $_[0]{raid} }
sub isPartOfLoopback { defined $_[0]{loopback} }
-sub isRAID { $_[0]{device} =~ /^md/ }
+sub isRAID { $_[0]{device} =~ /^md/ && defined $_[0]{level} }
sub isUBD { $_[0]{device} =~ /^ubd/ } #- should be always true during an $::uml_install
sub isLVM { $_[0]{VG_name} || $_[0]{lv_name} }
+sub isLUKS { defined $_[0]{dmcrypt_name} }
sub isLoopback { defined $_[0]{loopback_file} }
sub isMounted { $_[0]{isMounted} }
sub isBusy { isMounted($_[0]) || isPartOfRAID($_[0]) || isPartOfLVM($_[0]) || $_[0]{dm_active} || isPartOfLoopback($_[0]) }
diff --git a/perl-install/fs/wild_device.pm b/perl-install/fs/wild_device.pm
index f2383b6db..efb48d9d7 100644
--- a/perl-install/fs/wild_device.pm
+++ b/perl-install/fs/wild_device.pm
@@ -1,4 +1,4 @@
-package fs::wild_device; # $Id: wild_device.pm 250502 2008-12-16 10:25:09Z pixel $
+package fs::wild_device; # $Id: wild_device.pm 268572 2010-05-11 16:42:46Z pterjan $
use diagnostics;
use strict;
@@ -44,7 +44,7 @@ sub to_subpart {
($part{major}, $part{minor}) = unmakedev($rdev);
}
- my $symlink = readlink("$::prefix$dev");
+ my $symlink = readlink("$::prefix$dev") unless $dev =~ m!mapper/!;
$dev =~ s!/u?dev/!!;
if ($symlink && $symlink !~ m!^/!) {