summaryrefslogtreecommitdiffstats
path: root/perl-install/fs.pm
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/fs.pm')
-rw-r--r--perl-install/fs.pm29
1 files changed, 29 insertions, 0 deletions
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index 9d3c38049..3d9628071 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -305,6 +305,35 @@ sub umount_all($;$) {
}
}
+sub df {
+ my ($part, $prefix) = @_;
+ my $dir = "/tmp/tmp_fs_df";
+
+ return $part->{free} if exists $part->{free};
+
+ if ($part->{isMounted}) {
+ $dir = ($prefix || '') . $part->{mntpoint};
+ } elsif ($part->{notFormatted} && !$part->{isFormatted}) {
+ return; #- won't even try!
+ } else {
+ mkdir $dir;
+ eval { mount($part->{device}, $dir, type2fs($part->{type}), 'readonly') };
+ if ($@) {
+ unlink $dir;
+ return;
+ }
+ }
+ my (undef, $free) = common::df($dir);
+
+ if (!$part->{isMounted}) {
+ umount($dir);
+ unlink($dir)
+ }
+
+ $part->{free} = 2 * $free if defined $free;
+ $part->{free};
+}
+
#- do some stuff before calling write_fstab
sub write($$$$) {
my ($prefix, $fstab, $manualFstab, $useSupermount) = @_;