summaryrefslogtreecommitdiffhomepage
path: root/Plugins
diff options
context:
space:
mode:
authorJose A Ortega Ruiz <jao@gnu.org>2010-02-16 22:56:56 +0100
committerJose A Ortega Ruiz <jao@gnu.org>2010-02-16 22:56:56 +0100
commitf3f5a047efe49530fa730912c8f80d4c57b53347 (patch)
treeaa508816553776efe0a5b8f3a8ac086ec3170a76 /Plugins
parente7d5982ae3d457430e9ae1723e398511db2bcd52 (diff)
downloadxmobar-f3f5a047efe49530fa730912c8f80d4c57b53347.tar.gz
xmobar-f3f5a047efe49530fa730912c8f80d4c57b53347.tar.bz2
Documenting that flags must be passed to cabal _install_
Ignore-this: 30cf6bf6382573808029b6650a20564 darcs-hash:20100216215656-748be-762a06cee059c8fd1083e964a4e03f455568a5af.gz
Diffstat (limited to 'Plugins')
-rw-r--r--Plugins/Monitors/Disk.hs2
-rw-r--r--Plugins/Monitors/StatFS.hsc71
2 files changed, 1 insertions, 72 deletions
diff --git a/Plugins/Monitors/Disk.hs b/Plugins/Monitors/Disk.hs
index 3a9a70f..c0d8de7 100644
--- a/Plugins/Monitors/Disk.hs
+++ b/Plugins/Monitors/Disk.hs
@@ -17,7 +17,7 @@ module Plugins.Monitors.Disk ( diskUConfig, runDiskU
) where
import Plugins.Monitors.Common
-import Plugins.Monitors.StatFS
+import StatFS
import Control.Monad (zipWithM)
import qualified Data.ByteString.Lazy.Char8 as B
diff --git a/Plugins/Monitors/StatFS.hsc b/Plugins/Monitors/StatFS.hsc
deleted file mode 100644
index 9c1972c..0000000
--- a/Plugins/Monitors/StatFS.hsc
+++ /dev/null
@@ -1,71 +0,0 @@
------------------------------------------------------------------------------
--- |
--- Module : Plugins.Monitors.StatFS
--- Copyright : (c) Jose A Ortega Ruiz
--- License : BSD-style (see LICENSE)
---
--- Maintainer : Jose A Ortega Ruiz <jao@gnu.org>
--- Stability : unstable
--- Portability : unportable
---
--- A binding to C's statvfs(2)
---
------------------------------------------------------------------------------
-
-{-# LANGUAGE CPP, ForeignFunctionInterface, EmptyDataDecls #-}
-
-
-module Plugins.Monitors.StatFS ( FileSystemStats(..)
- , getFileSystemStats ) where
-
-import Foreign
-import Foreign.C.Types
-import Foreign.C.String
-import Data.ByteString (useAsCString)
-import Data.ByteString.Char8 (pack)
-
-#include <sys/vfs.h>
-
-data FileSystemStats = FileSystemStats {
- fsStatBlockSize :: Integer
- -- ^ Optimal transfer block size.
- , fsStatBlockCount :: Integer
- -- ^ Total data blocks in file system.
- , fsStatByteCount :: Integer
- -- ^ Total bytes in file system.
- , fsStatBytesFree :: Integer
- -- ^ Free bytes in file system.
- , fsStatBytesAvailable :: Integer
- -- ^ Free bytes available to non-superusers.
- , fsStatBytesUsed :: Integer
- -- ^ Bytes used.
- } deriving (Show, Eq)
-
-data CStatfs
-
-foreign import ccall unsafe "sys/vfs.h statfs64"
- c_statfs :: CString -> Ptr CStatfs -> IO CInt
-
-toI :: CLong -> Integer
-toI = toInteger
-
-getFileSystemStats :: String -> IO (Maybe FileSystemStats)
-getFileSystemStats path =
- allocaBytes (#size struct statfs) $ \vfs ->
- useAsCString (pack path) $ \cpath -> do
- res <- c_statfs cpath vfs
- 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
- bavail <- (#peek struct statfs, f_bavail) vfs
- let bpb = toI bsize
- return $ Just FileSystemStats
- { fsStatBlockSize = bpb
- , fsStatBlockCount = toI bcount
- , fsStatByteCount = toI bcount * bpb
- , fsStatBytesFree = toI bfree * bpb
- , fsStatBytesAvailable = toI bavail * bpb
- , fsStatBytesUsed = toI (bcount - bfree) * bpb
- }