From ca515b773e51493aee36d67a5893af33101493b1 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 4 Mar 2017 12:02:55 +0000 Subject: Revised fix for clearing GPT partitions during automatic install. This reverts commit 532fd1d60df306e204bae79c5158ca2302739966, which introduced a new bug when clearing GPT partitions in an interactive session (mga#20264), and replaces it with a new solution. When a partition table is initialised, we now add an 'init' action to the $hd->{will_tell_kernel} list. This is used both by gpt::write() (to clear the partition table) and by partition_table::tell_kernel() (to force the kernel to reread the partition table). Previous changes stored in $hd->{will_tell_kernel} are discarded, as they are no longer of interest. This also removes support for the will_tell_kernel 'force_reboot' action, as nothing uses that any more. --- perl-install/partition_table/gpt.pm | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'perl-install/partition_table/gpt.pm') diff --git a/perl-install/partition_table/gpt.pm b/perl-install/partition_table/gpt.pm index 7beecb335..f2f39f00c 100644 --- a/perl-install/partition_table/gpt.pm +++ b/perl-install/partition_table/gpt.pm @@ -81,9 +81,6 @@ sub write { $partitions_killed = 1; } - # sync libparted view with diskdrake one in order to prevent overlapping errors when adding partitions: - c::disk_delete_all($hd->{file}) if delete $hd->{sync_with_libparted}; - foreach (@{$hd->{will_tell_kernel}}) { my ($action, $part_number, $o_start, $o_size) = @$_; my ($part) = grep { $_->{start} == $o_start && $_->{size} == $o_size } @$pt; @@ -107,6 +104,8 @@ sub write { } } elsif ($action eq 'del' && !$partitions_killed) { c::disk_del_partition($hd->{file}, $part_number) or die "failed to del partition #$part_number on $hd->{file}"; + } elsif ($action eq 'init' && !$partitions_killed) { + c::disk_delete_all($hd->{file}) or die "failed to delete all partitions on $hd->{file}"; } } # prevent errors when telling kernel to reread partition table: @@ -118,8 +117,6 @@ sub write { sub initialize { my ($class, $hd) = @_; - # sync libparted view with diskdrake one in order to prevent overlapping errors when adding partitions: - $hd->{sync_with_libparted} = 1; # part_number starts at 1 my @raw = map { +{ part_number => $_ + 1 } } 0..$nb_primary-2; $hd->{primary} = { raw => \@raw }; -- cgit v1.2.1