From 7d4d754f92a3c0f78f4adc474392013749d85972 Mon Sep 17 00:00:00 2001 From: Jose A Ortega Ruiz Date: Sun, 14 Feb 2010 04:08:23 +0100 Subject: Less resource hungry top monitors Ignore-this: 920f60d81166f87370d20d779ed738c9 darcs-hash:20100214030823-748be-bde07719a3b3658a63bb1b687fec6c4c74b1f566.gz --- Plugins/Monitors/StatFS.hsc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'Plugins/Monitors/StatFS.hsc') diff --git a/Plugins/Monitors/StatFS.hsc b/Plugins/Monitors/StatFS.hsc index ad3b659..9c1972c 100644 --- a/Plugins/Monitors/StatFS.hsc +++ b/Plugins/Monitors/StatFS.hsc @@ -15,12 +15,12 @@ {-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-} -module Plugins.Monitors.StatFS (FileSystemStats(..), getFileSystemStats) where +module Plugins.Monitors.StatFS ( FileSystemStats(..) + , getFileSystemStats ) where import Foreign import Foreign.C.Types import Foreign.C.String -import Foreign.Storable import Data.ByteString (useAsCString) import Data.ByteString.Char8 (pack) @@ -54,9 +54,8 @@ getFileSystemStats path = allocaBytes (#size struct statfs) $ \vfs -> useAsCString (pack path) $ \cpath -> do res <- c_statfs cpath vfs - case res of - -1 -> return Nothing - _ -> do + if res == -1 then return Nothing + else do bsize <- (#peek struct statfs, f_bsize) vfs bcount <- (#peek struct statfs, f_blocks) vfs bfree <- (#peek struct statfs, f_bfree) vfs -- cgit v1.2.3