diff options
author | Jos Dehaes <jos.dehaes@gmail.com> | 2021-10-04 15:15:55 +0200 |
---|---|---|
committer | Jos Dehaes <jos.dehaes@gmail.com> | 2021-10-04 15:15:55 +0200 |
commit | c1e6d6a62e2810f80fac372e666ec169540b0591 (patch) | |
tree | 212df46c7ec044cd0858e877132317bc33de7099 /src/osx | |
parent | 50fcdaa8543f717bf36146cfa38636fd39009f23 (diff) |
show more disks
Diffstat (limited to 'src/osx')
-rw-r--r-- | src/osx/btop_collect.cpp | 27 |
1 files changed, 26 insertions, 1 deletions
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<string> 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<string> 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; |