summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-07-29 04:14:15 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-07-29 04:14:15 +0000
commitcc8452482c3c8441dbb5ad7114c4864ac6a85b0f (patch)
tree5f7ae8e383d4e0563fb38d17f8e0f76fc80a141e /perl-install/fsedit.pm
parentb82ae5700affc6b2cb5fe4081b3eea4a2219e363 (diff)
downloaddrakx-cc8452482c3c8441dbb5ad7114c4864ac6a85b0f.tar
drakx-cc8452482c3c8441dbb5ad7114c4864ac6a85b0f.tar.gz
drakx-cc8452482c3c8441dbb5ad7114c4864ac6a85b0f.tar.bz2
drakx-cc8452482c3c8441dbb5ad7114c4864ac6a85b0f.tar.xz
drakx-cc8452482c3c8441dbb5ad7114c4864ac6a85b0f.zip
merge hds() in get_hds() to correctly handle catching cdie when the device is non partionned
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r--perl-install/fsedit.pm73
1 files changed, 42 insertions, 31 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index c3bb56d6f..b4eeda85e 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -142,8 +142,8 @@ sub lvms {
@lvms;
}
-sub hds {
- my ($flags, $o_ask_before_blanking) = @_;
+sub get_hds {
+ my ($flags, $o_in) = @_;
$flags ||= {};
$flags->{readonly} && ($flags->{clearall} || $flags->{clear}) and die "conflicting flags readonly and clear/clearall";
@@ -162,8 +162,10 @@ sub hds {
if (my $err = $@) {
if ($err =~ /write error:/) {
$hd->{readonly} = 1;
+ } elsif ($err =~ /read error:/) {
+ next;
} else {
- cdie $err if $err !~ /read error:/;
+ $o_in and $o_in->ask_warn('', $err);
next;
}
}
@@ -171,20 +173,48 @@ sub hds {
if ($flags->{clearall} || member($hd->{device}, @{$flags->{clear} || []})) {
partition_table::raw::zero_MBR_and_dirty($hd);
} else {
- eval {
- partition_table::read($hd);
- compare_with_proc_partitions($hd) if $::isInstall;
- };
- if (my $err = $@) {
+ my $handle_die_and_cdie = sub {
if ($hd->{readonly}) {
log::l("using /proc/partitions since diskdrake failed :(");
use_proc_partitions($hd);
+ 1;
} elsif (exists $hd->{usb_description} && fs::type::fs_type_from_magic($hd)) {
#- non partitioned drive
$hd->{fs_type} = fs::type::fs_type_from_magic($hd);
push @raw_hds, $hd;
- next;
- } elsif ($o_ask_before_blanking && $o_ask_before_blanking->($hd->{device}, $err)) {
+ $hd = '';
+ 1;
+ } else {
+ 0;
+ }
+ };
+ my $handled;
+ eval {
+ catch_cdie {
+ partition_table::read($hd);
+ compare_with_proc_partitions($hd) if $::isInstall;
+ } sub {
+ my $err = $@;
+ if ($handle_die_and_cdie->()) {
+ $handled = 1;
+ 0; #- don't continue, transform cdie into die
+ } else {
+ !$o_in || $o_in->ask_okcancel('', formatError($err));
+ }
+ }
+ };
+ if (my $err = $@) {
+ if ($handled) {
+ #- already handled in cdie handler above
+ } elsif ($handle_die_and_cdie->()) {
+ } elsif ($o_in && $o_in->ask_yesorno(N("Error"),
+N("I can't read the partition table of device %s, it's too corrupted for me :(
+I can try to go on, erasing over bad partitions (ALL DATA will be lost!).
+The other solution is to not allow DrakX to modify the partition table.
+(the error is %s)
+
+Do you agree to lose all the partitions?
+ ", $hd->{device}, formatError($err)))) {
partition_table::raw::zero_MBR($hd);
} else {
#- using it readonly
@@ -192,6 +222,8 @@ sub hds {
use_proc_partitions($hd);
}
}
+ $hd or next;
+
member($_->{device}, @{$flags->{clear} || []}) and partition_table::remove($hd, $_)
foreach partition_table::get_normal_parts($hd);
}
@@ -233,27 +265,6 @@ sub hds {
$all_hds;
}
-sub get_hds {
- #- $in is optional
- my ($flags, $o_in) = @_;
-
- if ($o_in) {
- catch_cdie { hds($flags, sub {
- my ($dev, $err) = @_;
- $o_in->ask_yesorno(N("Error"),
-N("I can't read the partition table of device %s, it's too corrupted for me :(
-I can try to go on, erasing over bad partitions (ALL DATA will be lost!).
-The other solution is to not allow DrakX to modify the partition table.
-(the error is %s)
-
-Do you agree to lose all the partitions?
-", $dev, formatError($err)));
- }) } sub { $o_in->ask_okcancel('', formatError($@)) };
- } else {
- catch_cdie { hds($flags) } sub { 1 }
- }
-}
-
sub read_proc_partitions {
my ($hds) = @_;