From af4fa8371fa40bb5012a7af40f0f667059e8a138 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 12 Mar 2017 18:51:16 +0000 Subject: Ensure kernel is informed when a DOS partition table is cleared. diskdrake allows the user to clear all partitions even when some of those partitions are currently mounted. partition_table::dos::need_to_tell_kernel() must return true in this case, as the automatic reread of the partition table triggered by udevd will fail. --- perl-install/partition_table/dos.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'perl-install/partition_table') diff --git a/perl-install/partition_table/dos.pm b/perl-install/partition_table/dos.pm index 135d02208..a97fcf89d 100644 --- a/perl-install/partition_table/dos.pm +++ b/perl-install/partition_table/dos.pm @@ -288,13 +288,18 @@ sub need_to_tell_kernel { # The udev/rules.d/60-block.rules file causes the raw disk devices to be watched by udev. This file is # not present in the cut-down system used to run the classic installer, so we always need to tell the # kernel in that case. - return ! -e '/usr/lib/udev/rules.d/60-block.rules' || any { $_->{isMounted} } partition_table::get_normal_parts($hd); + # diskdrake will not let the user delete an individual partition that is mounted, but will let the + # user clear all partitions. So initialize() records if any partitions were mounted and we take note + # of that here. + return ! -e '/usr/lib/udev/rules.d/60-block.rules' || delete $hd->{hadMountedPartitions} || any { $_->{isMounted} } partition_table::get_normal_parts($hd); } sub empty_raw { { raw => [ ({}) x $nb_primary ] } } sub initialize { my ($class, $hd) = @_; + # Remember whether any existing partitions are mounted, for use by need_to_tell_kernel(). + $hd->{hadMountedPartitions} = 1 if any { $_->{isMounted} } partition_table::get_normal_parts($hd); $hd->{primary} = empty_raw(); bless $hd, $class; } -- cgit v1.2.1