commit 9f0df9de1afd7736d100fc459edf4acf0257928c Author: Harald Judt Date: Tue Apr 24 20:38:10 2012 +0200 Linux: Init device before gathering stats. 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. diff --git a/panel-plugin/main.c b/panel-plugin/main.c index 70f7a6c..03d6d50 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)