summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--news.md10
-rw-r--r--src/Plugins/Monitors/Disk.hs19
-rw-r--r--src/StatFS.hsc6
3 files changed, 21 insertions, 14 deletions
diff --git a/news.md b/news.md
index 24dd1a1..963f5c5 100644
--- a/news.md
+++ b/news.md
@@ -4,11 +4,17 @@
_New features_
- - New monitor AutoMPD, which uses asynchronous events to display MPD
- status (thanks to Ben Boeckel).
+ - New monitor `AutoMPD`, which uses asynchronous events to display
+ MPD status (thanks to Ben Boeckel).
- Dependencies updated to latest mtl and libmpd (thanks to Sergei
Trofimovich).
+_Bug fixes_
+
+ - `DiskU`, the disk usage monitor, works again correctly on Linux,
+ instead of randomly crashing every now and then, and reporting
+ wrong used size.
+
## Version 0.15 (June 4, 2012)
_Incompatible changes_
diff --git a/src/Plugins/Monitors/Disk.hs b/src/Plugins/Monitors/Disk.hs
index 725fe29..554be05 100644
--- a/src/Plugins/Monitors/Disk.hs
+++ b/src/Plugins/Monitors/Disk.hs
@@ -77,15 +77,6 @@ parseDev dat dev =
dat' = if length xs > 6 then [sp, rSp, wSp] else [0, 0, 0]
in (dev, dat')
-fsStats :: String -> IO [Integer]
-fsStats path = do
- stats <- getFileSystemStats path
- case stats of
- Nothing -> return [0, 0, 0]
- Just f -> let tot = fsStatByteCount f
- free = fsStatBytesAvailable f
- in return [tot, free, tot - free]
-
speedToStr :: Float -> String
speedToStr = showWithUnits 2 1
@@ -131,6 +122,16 @@ startDiskIO disks args rate cb = do
_ <- mountedData dref (map fst mounted)
runM args diskIOConfig (runDiskIO dref disks) rate cb
+fsStats :: String -> IO [Integer]
+fsStats path = do
+ stats <- getFileSystemStats path
+ case stats of
+ Nothing -> return [0, 0, 0]
+ Just f -> let tot = fsStatByteCount f
+ free = fsStatBytesAvailable f
+ used = fsStatBytesUsed f
+ in return [tot, free, used]
+
runDiskU' :: String -> String -> Monitor String
runDiskU' tmp path = do
setConfigValue tmp template
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
}