From 792e0bae67da7aa7f6556eaa72fc03e72e073d51 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 18 Mar 2020 10:11:57 +0100 Subject: (_get_dir_for_online_resize) split it --- perl-install/diskdrake/interactive.pm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/perl-install/diskdrake/interactive.pm b/perl-install/diskdrake/interactive.pm index 2c50c6078..0b449a460 100644 --- a/perl-install/diskdrake/interactive.pm +++ b/perl-install/diskdrake/interactive.pm @@ -757,6 +757,19 @@ sub Mount_point_raw_hd { $part->{mntpoint} = $mntpoint; } +#- side-effects: mounts the fs +sub _get_dir_for_online_resize { + my ($part) = @_; + my $dir = "/tmp/tmp_resize_" . $part->{fs_type} . ".$$"; + if ($part->{isMounted}) { + $dir = ($::prefix || '') . $part->{mntpoint}; + } else { + mkdir_p($dir); + fs::mount::mount(devices::make($part->{device}), $dir, $part->{fs_type}); + } + return $dir; +} + sub Resize { my ($in, $hd, $part) = @_; my (%nice_resize); @@ -893,13 +906,7 @@ filesystem checks will be run on your next boot into Microsoft Windows®")); #- happens only with mounted LVM, see above run_program::run_or_die("xfs_growfs", $part->{mntpoint}); } elsif ($nice_resize{btrfs}) { - my $dir = "/tmp/tmp_resize_btrfs.$$"; - if ($part->{isMounted}) { - $dir = ($::prefix || '') . $part->{mntpoint}; - } else { - mkdir_p($dir); - fs::mount::mount(devices::make($part->{device}), $dir, $part->{fs_type}); - } + my $dir = _get_dir_for_online_resize($part); if (!run_program::run(qw(btrfs filesystem resize), $part->{size}*512, $dir)) { $nice_resize{btrfs} = undef; # we just mounted it in order to do online resize but online resize failed: -- cgit v1.2.1