summaryrefslogtreecommitdiffhomepage
path: root/src/StatFS.hsc
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2012-07-28 21:21:35 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2012-07-28 21:21:35 +0200
commitededb764b496669013198419a56f2ee513d52587 (patch)
tree0f0379bc60ea332aed032c17e5218358af6b0a62 /src/StatFS.hsc
parent42f47c612a5aa113bdb5637c56c5bfaa1a98d846 (diff)
downloadxmobar-ededb764b496669013198419a56f2ee513d52587.tar.gz
xmobar-ededb764b496669013198419a56f2ee513d52587.tar.bz2
Fixes for DiskU, which was exploding on recent Linux
We're using now the recommended statvfs interface, instead of the obsolete statfs64. Moreover, we compute correctly the used space.
Diffstat (limited to 'src/StatFS.hsc')
-rw-r--r--src/StatFS.hsc6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/StatFS.hsc b/src/StatFS.hsc
index e1cb89c..050c19b 100644
--- a/src/StatFS.hsc
+++ b/src/StatFS.hsc
@@ -54,7 +54,7 @@ data CStatfs
#ifdef IS_BSD_SYSTEM
foreign import ccall unsafe "sys/mount.h statfs"
#else
-foreign import ccall unsafe "sys/vfs.h statfs64"
+foreign import ccall unsafe "sys/statvfs.h statvfs"
#endif
c_statfs :: CString -> Ptr CStatfs -> IO CInt
@@ -66,7 +66,7 @@ getFileSystemStats path =
allocaBytes (#size struct statfs) $ \vfs ->
useAsCString (pack path) $ \cpath -> do
res <- c_statfs cpath vfs
- if res == -1 then return Nothing
+ if res /= 0 then return Nothing
else do
bsize <- (#peek struct statfs, f_bsize) vfs
bcount <- (#peek struct statfs, f_blocks) vfs
@@ -79,5 +79,5 @@ getFileSystemStats path =
, fsStatByteCount = toI bcount * bpb
, fsStatBytesFree = toI bfree * bpb
, fsStatBytesAvailable = toI bavail * bpb
- , fsStatBytesUsed = toI (max 0 (bcount - bavail)) * bpb
+ , fsStatBytesUsed = toI (bcount - bfree) * bpb
}