[Xfce4-commits] <xfce4-diskperf-plugin:master> Linux: Init device before gathering stats. (bug #6749)
Landry Breuil
noreply at xfce.org
Wed Apr 25 19:44:03 CEST 2012
Updating branch refs/heads/master
to 1aa0ff06b6509529c811ca9192a4fdfab61affca (commit)
from ad59251801e95013b8c5b9b38119b607ac2a41f9 (commit)
commit 1aa0ff06b6509529c811ca9192a4fdfab61affca
Author: Harald Judt <h.judt at gmx.at>
Date: Wed Apr 25 19:42:26 2012 +0200
Linux: Init device before gathering stats. (bug #6749)
Init the device when it has not been done before. This enables
monitoring when a device becomes re-/attached after panel startup.
Useful for monitoring removable devices like USB sticks.
panel-plugin/main.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/panel-plugin/main.c b/panel-plugin/main.c
index 5f825e0..25046bf 100644
--- a/panel-plugin/main.c
+++ b/panel-plugin/main.c
@@ -153,6 +153,9 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
struct param_t *poConf = &(p_poPlugin->oConf.oParam);
struct monitor_t *poMonitor = &(p_poPlugin->oMonitor);
struct perfbar_t *poPerf = poMonitor->aoPerfBar;
+#if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(__sun__)
+ struct stat oStat;
+#endif
uint64_t iInterval_ns, rbytes, wbytes, iRBusy_ns, iWBusy_ns;
const double K = 1.0 * 1000 * 1000 * 1000 / 1024 / 1024;
/* bytes/ns --> MB/s */
@@ -169,6 +172,8 @@ static int DisplayPerf (struct diskperf_t *p_poPlugin)
#if defined (__NetBSD__) || defined(__OpenBSD__) || defined(__sun__)
status = DevGetPerfData (poConf->acDevice, &oPerf);
#else
+ if (poConf->st_rdev == 0)
+ poConf->st_rdev = (stat (poConf->acDevice, &oStat) == -1 ? 0 : oStat.st_rdev);
status = DevGetPerfData (&(poConf->st_rdev), &oPerf);
#endif
if (status == -1) {
More information about the Xfce4-commits
mailing list