From 48644a537553d6d6afde14ebd03c5d4742d5e7b4 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Wed, 7 Oct 2009 15:41:32 +0000 Subject: fix df on mips, statfs structure is different from x86 (from Arnaud Patard) --- NEWS | 1 + lib/MDK/Common/System.pm | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 000e38f..7b2e039 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ Version 1.2.20 - 13 August 2009, by Aurelien Lefebvre - Call fsync after writing to ensure that files are written +- fix df on mips, statfs structure is different from x86 Version 1.2.19 - 09 June 2009, by Eugeni Dodonov diff --git a/lib/MDK/Common/System.pm b/lib/MDK/Common/System.pm index 1b24f21..f7d0f63 100644 --- a/lib/MDK/Common/System.pm +++ b/lib/MDK/Common/System.pm @@ -310,7 +310,13 @@ sub df { my ($blocksize, $size, $free); my $buf = ' ' x 20000; syscall_('statfs', $mntpoint, $buf) or return; - (undef, $blocksize, $size, $free, undef, undef) = unpack "L!6", $buf; + # 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; } -- cgit v1.2.1