summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rigaux <pixel@mandriva.com>2001-09-13 15:08:33 +0000
committerPascal Rigaux <pixel@mandriva.com>2001-09-13 15:08:33 +0000
commitf7b310c01e3cfbae5cef8589ba8742c272ba32b6 (patch)
tree62da2b9b511101ff7cb0bfe5f9c6df4b4d8b2d75
parent87388f86fb9f49498bd6218b60c7ff63197ad67f (diff)
downloaddrakx-f7b310c01e3cfbae5cef8589ba8742c272ba32b6.tar
drakx-f7b310c01e3cfbae5cef8589ba8742c272ba32b6.tar.gz
drakx-f7b310c01e3cfbae5cef8589ba8742c272ba32b6.tar.bz2
drakx-f7b310c01e3cfbae5cef8589ba8742c272ba32b6.tar.xz
drakx-f7b310c01e3cfbae5cef8589ba8742c272ba32b6.zip
BLKPG_ADD_PARTITION support (aka adding partition on the fly without rebooting on a device with some already mounted partitions)
-rw-r--r--perl-install/partition_table.pm23
1 files changed, 18 insertions, 5 deletions
diff --git a/perl-install/partition_table.pm b/perl-install/partition_table.pm
index 9b23ff709..54483fdc5 100644
--- a/perl-install/partition_table.pm
+++ b/perl-install/partition_table.pm
@@ -536,8 +536,18 @@ sub write {
$hd->{isDirty} = 0;
$hd->{hasBeenDirty} = 1; #- used in undo (to know if undo should believe isDirty or not)
- #- now sync disk and re-read the partition table
- if ($hd->{needKernelReread}) {
+ if ($hd->{needKernelReread} && ref($hd->{needKernelReread}) eq 'ARRAY' && $::isStandalone) {
+ #- we've only been adding partitions. Try special add_partition (using BLKPG_ADD_PARTITION)
+ local *F;
+ partition_table_raw::openit($hd, *F) or goto force_reread;
+
+ foreach (@{$hd->{needKernelReread}}) {
+ c::add_partition(fileno F, $_->{start}, $_->{size}, $_->{device} =~ /(\d+)$/)
+ or goto force_reread;
+ }
+ } elsif ($hd->{needKernelReread}) {
+ force_reread:
+ #- now sync disk and re-read the partition table
common::sync();
my @magic_parts = grep { $_->{isMounted} && $_->{real_mntpoint} } get_normal_parts($hd);
@@ -548,8 +558,8 @@ sub write {
foreach (@magic_parts) {
syscall_('mount', , $_->{real_mntpoint}, type2fs($_), c::MS_MGC_VAL()) or log::l(_("mount failed: ") . "$!");
}
- $hd->{needKernelReread} = 0;
}
+ $hd->{needKernelReread} = 0;
}
sub active {
@@ -664,7 +674,6 @@ sub add {
$part->{notFormatted} = 1;
$part->{isFormatted} = 0;
$part->{rootDevice} = $hd->{device};
- $hd->{isDirty} = $hd->{needKernelReread} = 1;
$part->{start} ||= 1 if arch() !~ /^sparc/; #- starting at sector 0 is not allowed
adjustStartAndEnd($hd, $part) unless $forceNoAdjust;
@@ -675,13 +684,17 @@ sub add {
$primaryOrExtended eq 'Primary' ||
$primaryOrExtended !~ /Extended/ && @{$hd->{primary}{normal} || []} < $nb_primaries) {
eval { add_primary($hd, $part) };
- return unless $@;
+ goto success if !$@;
}
eval { add_extended($hd, $part, $primaryOrExtended) } if $hd->hasExtended; #- try adding extended
if ($@ || !$hd->hasExtended) {
eval { add_primary($hd, $part) };
die $@ if $@; #- send the add extended error which should be better
}
+ success:
+ assign_device_numbers($hd);
+ $hd->{isDirty} = 1;
+ push @{$hd->{needKernelReread} ||= []}, $part if !$hd->{needKernelReread} || ref($hd->{needKernelReread}) eq 'ARRAY'
}
# search for the next partition