summaryrefslogtreecommitdiffstats
path: root/perl-install/diskdrake/interactive.pm
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2004-01-15 11:27:12 +0000
committerPascal Rigaux <pixel@mandriva.com>2004-01-15 11:27:12 +0000
commita0092a3d667863341339645f5d0bc9bc4b4b5108 (patch)
treed9a24e421b0ed945ff3d3bced57634cd68e5776f /perl-install/diskdrake/interactive.pm
parent28a23a084b62594b9acf2d0f4d2dd3e7dad60ed8 (diff)
downloaddrakx-a0092a3d667863341339645f5d0bc9bc4b4b5108.tar
drakx-a0092a3d667863341339645f5d0bc9bc4b4b5108.tar.gz
drakx-a0092a3d667863341339645f5d0bc9bc4b4b5108.tar.bz2
drakx-a0092a3d667863341339645f5d0bc9bc4b4b5108.tar.xz
drakx-a0092a3d667863341339645f5d0bc9bc4b4b5108.zip
- remove the use of BLKRRPART (telling the kernel to re-read the partition table) in most cases
- replace with tell_kernel() and will_tell_kernel() - correctly handle in standalone the need to reboot, with no way to forget it (telling the WM to quit nicely then call reboot when it's done)
Diffstat (limited to 'perl-install/diskdrake/interactive.pm')
-rw-r--r--perl-install/diskdrake/interactive.pm52
1 files changed, 43 insertions, 9 deletions
diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm
index 67c9cb721..e9acaf4e6 100644
--- a/perl-install/diskdrake/interactive.pm
+++ b/perl-install/diskdrake/interactive.pm
@@ -110,7 +110,7 @@ struct hd {
bool readonly # is it allowed to modify the partition table
bool getting_rid_of_readonly_allowed # is it forbidden to write because the partition table is badly handled, or is it because we MUST not change the partition table
bool isDirty # does it need to be written to the disk
- bool needKernelReread # must we tell the kernel to reread the partition table
+ list will_tell_kernel # list of actions to tell to the kernel so that it knows the new partition table
bool hasBeenDirty # for undo
bool rebootNeeded # happens when a kernel reread failed
bool partitionsRenumbered # happens when you
@@ -142,7 +142,7 @@ struct raw_hd inherits hd {
string mntpoint # '/', '/usr' ...
string options # 'defaults', 'noauto'
- # invalid: isDirty, needKernelReread, hasBeenDirty, rebootNeeded, primary, extended
+ # invalid: isDirty, will_tell_kernel, hasBeenDirty, rebootNeeded, primary, extended
}
struct all_hds {
@@ -259,7 +259,7 @@ sub Done {
$in->ask_okcancel('', [ formatError($err), N("Continue anyway?") ]) or return;
}
foreach (@{$all_hds->{hds}}) {
- if (!write_partitions($in, $_)) {
+ if (!write_partitions($in, $_, 'skip_check_rebootNeeded')) {
return if !$::isStandalone;
$in->ask_yesorno(N("Quit without saving"), N("Quit without writing the partition table?"), 1) or return;
}
@@ -270,6 +270,10 @@ sub Done {
$all_hds->{current_fstab} = $new;
fs::write_fstab($all_hds);
}
+ if (any { $_->{rebootNeeded} } @{$all_hds->{hds}}) {
+ $in->ask_warn('', N("You need to reboot for the partition table modifications to take place"));
+ tell_wm_and_reboot();
+ }
}
1;
}
@@ -705,7 +709,6 @@ sub Resize {
$part->{size} == $size and return;
my $oldsize = $part->{size};
- $hd->{isDirty} = $hd->{needKernelReread} = 1;
$part->{size} = $size;
$hd->adjustEnd($part);
@@ -715,6 +718,8 @@ sub Resize {
my $adjust = sub {
my ($write_partitions) = @_;
+ partition_table::will_tell_kernel($hd, resize => $part);
+
if (isLVM($hd)) {
lvm::lv_resize($part, $oldsize);
} else {
@@ -1043,16 +1048,20 @@ sub check {
check_mntpoint($in, $part->{mntpoint}, $hd, $part, $all_hds);
}
+sub check_rebootNeeded {
+ my ($_in, $hd) = @_;
+ $hd->{rebootNeeded} and die \N("You'll need to reboot before the modification can take place");
+}
+
sub write_partitions {
- my ($in, $hd) = @_;
+ my ($in, $hd, $b_skip_check_rebootNeeded) = @_;
+ check_rebootNeeded($in, $hd) if !$b_skip_check_rebootNeeded;
$hd->{isDirty} or return 1;
isLVM($hd) and return 1;
$in->ask_okcancel(N("Read carefully!"), N("Partition table of drive %s is going to be written to disk!", $hd->{device}), 1) or return;
- if (!$::testing) {
- partition_table::write($hd);
- }
- $hd->{rebootNeeded} and die \N("You'll need to reboot before the modification can take place");
+ partition_table::write($hd) if !$::testing;
+ check_rebootNeeded($in, $hd) if !$b_skip_check_rebootNeeded;
1;
}
@@ -1244,3 +1253,28 @@ sub choose_encrypt_key {
{ label => N("Encryption key (again)"), val => \$encrypt_key2, hidden => 1 },
]) && $encrypt_key;
}
+
+
+sub tell_wm_and_reboot() {
+ my ($wm, $pid) = any::running_window_manager();
+
+ if (!$wm) {
+ system('reboot');
+ } else {
+ if (fork()) {
+ any::ask_window_manager_to_logout($wm);
+ return;
+ }
+
+ open STDIN, "</dev/zero";
+ open STDOUT, ">/dev/null";
+ open STDERR, ">&STDERR";
+ c::setsid();
+ exec 'perl', '-e', q(
+ my ($wm, $pid) = @ARGV;
+ my $nb;
+ for ($nb = 20; $nb && -e "/proc/$pid"; $nb--) { sleep 1 }
+ exec 'reboot';
+ ), $wm, $pid;
+ }
+}