summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2007-09-19 14:57:17 +0000
committerPascal Rigaux <pixel@mandriva.com>2007-09-19 14:57:17 +0000
commit11b0e9fe0e06fc002cbb4df903dba1541fb88019 (patch)
treea65d1d60a01c99cd11e8118706abeb36906fc748
parent826763e26b59688ccbb0a5adc5a5e46a32fe532d (diff)
downloaddrakx-backup-do-not-use-11b0e9fe0e06fc002cbb4df903dba1541fb88019.tar
drakx-backup-do-not-use-11b0e9fe0e06fc002cbb4df903dba1541fb88019.tar.gz
drakx-backup-do-not-use-11b0e9fe0e06fc002cbb4df903dba1541fb88019.tar.bz2
drakx-backup-do-not-use-11b0e9fe0e06fc002cbb4df903dba1541fb88019.tar.xz
drakx-backup-do-not-use-11b0e9fe0e06fc002cbb4df903dba1541fb88019.zip
create partition_table_initialize() and partition_table_clear_and_initialize()
which are wrappers around partition_table::initialize() but which also create a singleton VG automatically (so that it's easier for the user)
-rw-r--r--perl-install/diskdrake/interactive.pm2
-rw-r--r--perl-install/fs/partitioning_wizard.pm2
-rw-r--r--perl-install/fsedit.pm22
-rw-r--r--perl-install/lvm.pm12
-rw-r--r--perl-install/partition_table/raw.pm7
5 files changed, 38 insertions, 7 deletions
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index 2c306efae..2de3bd2e5 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -327,7 +327,7 @@ sub Clear_all {
} else {
$hd->{readonly} = 0; #- give a way out of readonly-ness. only allowed when getting_rid_of_readonly_allowed
$hd->{getting_rid_of_readonly_allowed} = 0; #- we don't need this flag anymore
- partition_table::raw::clear_and_dirty($hd);
+ fsedit::partition_table_clear_and_initialize($all_hds->{lvms}, $hd, $in);
}
}
diff --git a/perl-install/fs/partitioning_wizard.pm b/perl-install/fs/partitioning_wizard.pm
index f1f668ab5..3c4ba602e 100644
--- a/perl-install/fs/partitioning_wizard.pm
+++ b/perl-install/fs/partitioning_wizard.pm
@@ -211,7 +211,7 @@ filesystem checks will be run on your next boot into Microsoft Windows®")) if $
title => N("Partitioning"),
icon => 'banner-part',
interactive_help_id => 'takeOverHdConfirm' }) or return;
- partition_table::raw::clear_and_dirty($hd);
+ fsedit::partition_table_clear_and_initialize($all_hds->{lvms}, $hd, $in);
fsedit::auto_allocate($all_hds, $partitions);
1;
} ];
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index 1dc809ac4..d1871dc48 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -167,7 +167,8 @@ sub get_hds {
}
if ($flags->{clearall} || member($hd->{device}, @{$flags->{clear} || []})) {
- partition_table::raw::zero_MBR_and_dirty($hd);
+ my $lvms = []; #- temporary one, will be re-created later in get_hds()
+ partition_table_initialize($lvms, $hd, $o_in);
} else {
my $handle_die_and_cdie = sub {
if (my $type = fs::type::type_subpart_from_magic($hd)) {
@@ -551,4 +552,23 @@ sub change_type {
1;
}
+sub partition_table_clear_and_initialize {
+ my ($lvms, $hd, $o_in, $o_type, $b_warn) = @_;
+ $hd->clear_existing;
+ partition_table_initialize($lvms, $hd, $o_in, $o_type, $b_warn);
+}
+
+sub partition_table_initialize {
+ my ($lvms, $hd, $o_in, $b_warn, $o_type) = @_;
+ partition_table::initialize($hd, $o_type);
+ if ($hd->isa('partition_table::lvm')) {
+ if ($b_warn && $o_in) {
+ $o_in->ask_okcancel_('', N("ALL existing partitions and their data will be lost on drive %s", partition_table::description($hd))) or return;
+ }
+ require lvm;
+ lvm::check($o_in ? $o_in->do_pkgs : do_pkgs_standalone->new) if $::isStandalone;
+ lvm::create_singleton_vg($lvms, fs::get::hds_fstab($hd));
+ }
+}
+
1;
diff --git a/perl-install/lvm.pm b/perl-install/lvm.pm
index decdfb376..e08d382d2 100644
--- a/perl-install/lvm.pm
+++ b/perl-install/lvm.pm
@@ -204,4 +204,16 @@ sub add_to_VG {
lvm::update_size($lvm);
}
+sub create_singleton_vg {
+ my ($lvms, $part) = @_;
+
+ my %existing = map { $_->{VG_name} => 1 } @$lvms;
+ my $VG_name = find { !$existing{$_} } map { "VG$_" } 1 .. 100 or internal_error();
+
+ my $lvm = new lvm($VG_name);
+ push @$lvms, $lvm;
+
+ add_to_VG($part, $lvm);
+}
+
1;
diff --git a/perl-install/partition_table/raw.pm b/perl-install/partition_table/raw.pm
index ab9fbba08..925ae6562 100644
--- a/perl-install/partition_table/raw.pm
+++ b/perl-install/partition_table/raw.pm
@@ -216,11 +216,10 @@ sub clear_existing {
partition_table::will_tell_kernel($hd, del => $_) foreach @parts;
}
-sub zero_MBR_and_dirty { &clear_and_dirty } #- deprecated
-sub clear_and_dirty {
+#- deprecated
+sub zero_MBR_and_dirty {
my ($hd) = @_;
- $hd->clear_existing;
- partition_table::initialize($hd);
+ fsedit::partition_table_clear_and_initialize([], $hd);
}
sub read_primary {