From 0f117a0273271f45908485ea1eebfefd31afee4b Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 26 Apr 2022 20:43:35 +0200 Subject: [PATCH] Fixed: Disk IO stats for individual partitions instead of whole disk --- src/linux/btop_collect.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/linux/btop_collect.cpp b/src/linux/btop_collect.cpp index 29d3396..595404d 100644 --- a/src/linux/btop_collect.cpp +++ b/src/linux/btop_collect.cpp @@ -911,12 +911,17 @@ namespace Mem { #endif if (disks.at(mountpoint).name.empty()) disks.at(mountpoint).name = (mountpoint == "/" ? "root" : mountpoint); string devname = disks.at(mountpoint).dev.filename(); + int c = 0; while (devname.size() >= 2) { if (fs::exists("/sys/block/" + devname + "/stat", ec) and access(string("/sys/block/" + devname + "/stat").c_str(), R_OK) == 0) { - disks.at(mountpoint).stat = "/sys/block/" + devname + "/stat"; + if (c > 0 and fs::exists("/sys/block/" + devname + '/' + disks.at(mountpoint).dev.filename().string() + "/stat", ec)) + disks.at(mountpoint).stat = "/sys/block/" + devname + '/' + disks.at(mountpoint).dev.filename().string() + "/stat"; + else + disks.at(mountpoint).stat = "/sys/block/" + devname + "/stat"; break; } devname.resize(devname.size() - 1); + c++; } }