From 7ebe4f7594599ccafbf72a004ce37f965549f64d Mon Sep 17 00:00:00 2001 From: Jos Dehaes Date: Mon, 4 Oct 2021 15:15:55 +0200 Subject: show more disks --- src/osx/btop_collect.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/osx/btop_collect.cpp b/src/osx/btop_collect.cpp index 0bcbad0..74bf85e 100644 --- a/src/osx/btop_collect.cpp +++ b/src/osx/btop_collect.cpp @@ -271,15 +271,40 @@ namespace Mem { } if (show_disks) { + auto& disks_filter = Config::getS("disks_filter"); + bool filter_exclude = false; + auto& only_physical = Config::getB("only_physical"); auto &disks = mem.disks; + vector filter; + if (not disks_filter.empty()) { + filter = ssplit(disks_filter); + if (filter.at(0).starts_with("exclude=")) { + filter_exclude = true; + filter.at(0) = filter.at(0).substr(8); + } + } + struct statfs *stfs; int count = getmntinfo(&stfs, MNT_WAIT); + vector found; + found.reserve(last_found.size()); for (int i = 0; i < count; i++) { std::error_code ec; string mountpoint = stfs[i].f_mntonname; - Logger::debug("found mountpoint " + mountpoint); string dev = stfs[i].f_mntfromname; disks[mountpoint] = disk_info{fs::canonical(dev, ec), fs::path(mountpoint).filename()}; + + //? Match filter if not empty + if (not filter.empty()) { + bool match = v_contains(filter, mountpoint); + if ((filter_exclude and match) or (not filter_exclude and not match)) + continue; + } + + found.push_back(mountpoint); + if (not v_contains(last_found, mountpoint)) redraw = true; + last_found = std::move(found); + if (disks.at(mountpoint).dev.empty()) disks.at(mountpoint).dev = dev; if (disks.at(mountpoint).name.empty()) disks.at(mountpoint).name = (mountpoint == "/" ? "root" : mountpoint); disks.at(mountpoint).free = stfs[i].f_bfree; -- cgit v1.2.3