summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Whitaker <mageia@martin-whitaker.me.uk>2019-04-20 11:02:52 +0100
committerMartin Whitaker <mageia@martin-whitaker.me.uk>2019-04-20 21:35:26 +0100
commit2fe536b25f66c52a75ed8c53cd5f14d9e795d6a3 (patch)
treec06371a109d24c62026410f1e50c1cbcfc80020e
parentac55dea6ae6cb38633631b18c74c76f452763cfd (diff)
downloaddrakx-2fe536b25f66c52a75ed8c53cd5f14d9e795d6a3.tar
drakx-2fe536b25f66c52a75ed8c53cd5f14d9e795d6a3.tar.gz
drakx-2fe536b25f66c52a75ed8c53cd5f14d9e795d6a3.tar.bz2
drakx-2fe536b25f66c52a75ed8c53cd5f14d9e795d6a3.tar.xz
drakx-2fe536b25f66c52a75ed8c53cd5f14d9e795d6a3.zip
Minimise calls to ped_disk_probe() when reading partition tables (mga#15752)
-rw-r--r--perl-install/partition_table.pm8
-rw-r--r--perl-install/partition_table/dos.pm2
-rw-r--r--perl-install/partition_table/gpt.pm2
3 files changed, 10 insertions, 2 deletions
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index da53822d1..f294dc809 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -298,6 +298,13 @@ Identify the partition table type of $hd and return a blessed $pt of type partit
sub read_primary {
my ($hd) = @_;
+ #- The libparted ped_disk_probe() function opens the raw device for R/W, which causes a
+ #- change event to be sent for every partition when the raw device is closed again. So
+ #- be careful not to call this function more than once. (mga#15752)
+ my $current = c::get_disk_type($hd->{file});
+ $current = 'dos' if $current eq 'msdos';
+ $hd->{current_pt_table_type} = $current;
+
#- it can be safely considered that the first sector is used to probe the partition table
#- but other sectors (typically for extended partition ones) have to match this type!
my @parttype = (
@@ -319,6 +326,7 @@ sub read_primary {
bless $hd, "partition_table::$_";
if ($hd->read_primary) {
log::l("found a $_ partition table on $hd->{file} at sector 0");
+ #- Don't rely on the type returned by libparted - use what we have discovered.
$hd->{pt_table_type} = $_ if $_ ne 'empty';
return 1;
}
diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm
index 51c82e108..3bcb226c4 100644
--- a/perl-install/partition_table/dos.pm
+++ b/perl-install/partition_table/dos.pm
@@ -238,7 +238,7 @@ sub read_one {
sysread $F, $tmp, length $magic or die "error reading magic number on disk $hd->{device}";
$tmp eq $magic or die "bad magic number on disk $hd->{device}";
- if (c::get_disk_type($hd->{file}) ne "msdos") {
+ if ($hd->{current_pt_table_type} ne "dos") {
# libparted may have ignored it because of overlapping partitions or other error
# while it is actually a partition table.
$hd->{fs_type_from_magic} and die "unpartitionned disk";
diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm
index c155ed48e..e1c07a761 100644
--- a/perl-install/partition_table/gpt.pm
+++ b/perl-install/partition_table/gpt.pm
@@ -45,7 +45,7 @@ $rev_parted_mapping{vfat} = 'fat32';
sub read_one {
my ($hd, $_sector) = @_;
- c::get_disk_type($hd->{file}) eq "gpt" or die "$hd->{device} not a GPT disk ($hd->{file})";
+ $hd->{current_pt_table_type} eq "gpt" or die "$hd->{device} not a GPT disk ($hd->{file})";
my @pt;
foreach (c::get_disk_partitions($hd->{file})) {