From 4116489d18c572826e532dce89c4cfe78dc67eba Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Wed, 7 Oct 2009 17:13:49 +0000 Subject: use a more portable df() --- NEWS | 1 + lib/MDK/Common/System.pm | 14 +++----------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/NEWS b/NEWS index 9bcefe6..8829814 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,4 @@ +- use a more portable df() - substInFile: o do not unlink the symlink to recreate it later to the same target diff --git a/lib/MDK/Common/System.pm b/lib/MDK/Common/System.pm index f7d0f63..bd13629 100644 --- a/lib/MDK/Common/System.pm +++ b/lib/MDK/Common/System.pm @@ -307,17 +307,9 @@ sub syscall_ { #- return the size of the partition and its free space in KiB sub df { my ($mntpoint) = @_; - my ($blocksize, $size, $free); - my $buf = ' ' x 20000; - syscall_('statfs', $mntpoint, $buf) or return; - # at least on mips the statfs structure is different to x86 - # Should we use bavail or bfree ? - if (arch() =~ /mips/) { - (undef, $blocksize, undef, $size, $free, undef, undef, $avail) = unpack "L!8", $buf; - } else { - (undef, $blocksize, $size, $free, undef, undef) = unpack "L!6", $buf; - } - map { $_ * ($blocksize / 1024) } $size, $free; + require Filesys::Df; + my $df = Filesys::Df::df("/", 1024); # ask 1kb values + @$df{qw(blocks bfree)}; } sub sync() { syscall_('sync') } -- cgit v1.2.1