summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJos Dehaes <jos.dehaes@gmail.com>2021-11-16 21:53:33 +0100
committerJos Dehaes <jos.dehaes@gmail.com>2021-11-16 21:53:33 +0100
commita6602ff22b4b00ecb7138a09f5c5a15e1b13ca62 (patch)
tree45b151c4b62498c542a4952ddb64528752df19c4
parente64610a163c23ec862c5f65d1accdd10a6163d47 (diff)
correctly iterate over devstat. still no idea how to map the devices we get back here to mountpoints
-rw-r--r--src/freebsd/btop_collect.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/freebsd/btop_collect.cpp b/src/freebsd/btop_collect.cpp
index 7e2be8d..5ffb7a5 100644
--- a/src/freebsd/btop_collect.cpp
+++ b/src/freebsd/btop_collect.cpp
@@ -478,12 +478,15 @@ namespace Mem {
static std::unique_ptr<struct devinfo, decltype(std::free)*> lastDevInfo (reinterpret_cast<struct devinfo*>(std::calloc(1, sizeof(struct devinfo))), std::free);
cur.dinfo = curDevInfo.get();
last.dinfo = lastDevInfo.get();
- int n = devstat_getdevs(NULL, &cur);
- for (int i = 0; i < n; i++) {
- devstat_compute_statistics(&cur.dinfo->devices[i], NULL, etime, DSM_TOTAL_BYTES_READ, &total_bytes_read,
- DSM_TOTAL_BYTES_WRITE, &total_bytes_write, DSM_NONE);
- Logger::debug("dev " + string(cur.dinfo->devices[i].device_name) + " read=" + std::to_string(total_bytes_read) + " write=" + std::to_string(total_bytes_write));
- }
+
+ if (devstat_getdevs(NULL, &cur) != -1) {
+ for (int i = 0; i < cur.dinfo->numdevs; i++) {
+ devstat_compute_statistics(&cur.dinfo->devices[i], NULL, etime, DSM_TOTAL_BYTES_READ, &total_bytes_read,
+ DSM_TOTAL_BYTES_WRITE, &total_bytes_write, DSM_NONE);
+ Logger::debug("dev " + string(cur.dinfo->devices[i].device_name) + std::to_string(cur.dinfo->devices[i].device_number) + " read=" + std::to_string(total_bytes_read) + " write=" + std::to_string(total_bytes_write));
+ }
+ Logger::debug("");
+ }
}
auto collect(const bool no_update) -> mem_info & {
@@ -565,7 +568,6 @@ namespace Mem {
std::error_code ec;
string mountpoint = stfs[i].f_mntonname;
string dev = stfs[i].f_mntfromname;
- Logger::debug(dev + "->" + mountpoint);
mapping[dev] = mountpoint;
if (string(stfs[i].f_fstypename) == "autofs") {