*
**************************************************************************/
-#if HAVE_GALLIUM_EXTRA_HUD
+#ifdef HAVE_GALLIUM_EXTRA_HUD
/* Purpose: Reading /sys/block/<*>/stat MB/s read/write throughput per second,
* displaying on the HUD.
#include "hud/hud_private.h"
#include "util/list.h"
-#include "os/os_time.h"
+#include "util/os_time.h"
#include "os/os_thread.h"
#include "util/u_memory.h"
+#include "util/u_string.h"
#include <stdio.h>
#include <unistd.h>
#include <dirent.h>
}
static void
-query_dsi_load(struct hud_graph *gr)
+query_dsi_load(struct hud_graph *gr, struct pipe_context *pipe)
{
/* The framework calls us periodically, compensate for the
* calling interval accordingly when reporting per second.
else if (dsi->mode == DISKSTAT_WR) {
snprintf(gr->name, sizeof(gr->name), "%s-Write-MB/s", dsi->name);
}
- else
+ else {
+ free(gr);
return;
+ }
gr->query_data = dsi;
gr->query_new_value = query_dsi_load;
{
struct diskstat_info *dsi = CALLOC_STRUCT(diskstat_info);
- strcpy(dsi->name, name);
+ snprintf(dsi->name, sizeof(dsi->name), "%s", name);
snprintf(dsi->sysfs_filename, sizeof(dsi->sysfs_filename), "%s/%s/stat",
basename, name);
dsi->mode = objmode;
{
struct diskstat_info *dsi = CALLOC_STRUCT(diskstat_info);
- strcpy(dsi->name, name);
+ snprintf(dsi->name, sizeof(dsi->name), "%s", name);
snprintf(dsi->sysfs_filename, sizeof(dsi->sysfs_filename), "%s/stat",
basename);
dsi->mode = objmode;
/* Return the number of block devices and partitions. */
mtx_lock(&gdiskstat_mutex);
if (gdiskstat_count) {
- pipe_mutex_unlock(gdiskstat_mutex);
+ mtx_unlock(&gdiskstat_mutex);
return gdiskstat_count;
}
list_inithead(&gdiskstat_list);
DIR *dir = opendir("/sys/block/");
if (!dir) {
- pipe_mutex_unlock(gdiskstat_mutex);
+ mtx_unlock(&gdiskstat_mutex);
return 0;
}
struct dirent *dpart;
DIR *pdir = opendir(basename);
if (!pdir) {
- pipe_mutex_unlock(gdiskstat_mutex);
+ mtx_unlock(&gdiskstat_mutex);
closedir(dir);
return 0;
}
puts(line);
}
}
- pipe_mutex_unlock(gdiskstat_mutex);
+ mtx_unlock(&gdiskstat_mutex);
return gdiskstat_count;
}