summaryrefslogtreecommitdiffstats
path: root/perl-install/fsedit.pm
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2020-11-19 19:42:08 +0000
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2020-11-19 19:42:08 +0000
commit80dadc0c749f5521377808360e4e9fa7aff7389b (patch)
tree6768be6791a9378b01fdb15b6eabd9cfdce784a1 /perl-install/fsedit.pm
parentc7ffac2610c088756c0709291b081b9a31079262 (diff)
downloaddrakx-80dadc0c749f5521377808360e4e9fa7aff7389b.tar
drakx-80dadc0c749f5521377808360e4e9fa7aff7389b.tar.gz
drakx-80dadc0c749f5521377808360e4e9fa7aff7389b.tar.bz2
drakx-80dadc0c749f5521377808360e4e9fa7aff7389b.tar.xz
drakx-80dadc0c749f5521377808360e4e9fa7aff7389b.zip
Fix a crash when detecting a mdadm RAID array (mga#26707)
get_hds() did not handle the case of a mdadm RAID array created using raw devices instead of partitions. The drakx tools never do this, but the user may have done it another way.
Diffstat (limited to 'perl-install/fsedit.pm')
-rw-r--r--perl-install/fsedit.pm20
1 files changed, 17 insertions, 3 deletions
diff --git a/perl-install/fsedit.pm b/perl-install/fsedit.pm
index e53648a37..d209b0196 100644
--- a/perl-install/fsedit.pm
+++ b/perl-install/fsedit.pm
@@ -82,11 +82,11 @@ sub recompute_loopbacks {
}
sub raids {
- my ($hds) = @_;
+ my ($hds, $raw_hds) = @_;
my @parts = fs::get::hds_fstab(@$hds);
- my @l = grep { isRawRAID($_) } @parts or return [];
+ my @l = grep { isRawRAID($_) } ( @parts, @$raw_hds ) or return [];
log::l("looking for raids in " . join(' ', map { $_->{device} } @l));
@@ -197,6 +197,20 @@ sub get_hds {
foreach my $hd (@drives) {
$hd->{readonly} = $flags->{readonly};
+ #- We only create RAID components in disk partitions, but users may have used
+ #- mdadm directly to create them on raw disk devices. Detect that now, before
+ #- looking for a partition table (which is likely to fail badly - mga#26707).
+ if (my $type = fs::type::type_subpart_from_magic($hd)) {
+ if (isRawRAID($type)) {
+ #- Add the necessary information to the raw device to allow the RAID
+ #- array to be properly characterised in diskdrake.
+ put_in_hash($hd, $type);
+ $hd->{size} = $hd->{totalsectors};
+ push @raw_hds, $hd;
+ next;
+ }
+ }
+
eval { partition_table::raw::test_for_bad_drives($hd) if !$flags->{no_bad_drives} };
if (my $err = $@) {
log::l("test_for_bad_drives returned $err");
@@ -310,7 +324,7 @@ Do you agree to lose all the partitions?
}
#- detect raids before LVM allowing LVM on raid
- my $raids = raids(\@hds);
+ my $raids = raids(\@hds, \@raw_hds);
my $all_hds = { %{ fs::get::empty_all_hds() }, hds => \@hds, raw_hds => \@raw_hds, lvms => [], raids => $raids };
$all_hds->{lvms} = [ lvms($all_hds) ];