Fixed: Get real / mountpoint when running inside snap

This commit is contained in:
aristocratos 2021-09-28 21:01:50 +02:00
parent ff6d1d6eec
commit 06cac6756d
2 changed files with 10 additions and 0 deletions

View file

@ -34,6 +34,7 @@ apps:
environment:
LC_ALL: C.UTF-8
LANG: C.UTF-8
BTOP_SNAPPED: true
plugs:
- mount-observe
- process-control

View file

@ -679,6 +679,7 @@ namespace Mem {
auto& swap_disk = Config::getB("swap_disk");
auto& show_disks = Config::getB("show_disks");
auto& mem = current_mem;
static const bool snapped = (getenv("BTOP_SNAPPED") != NULL);
mem.stats.at("swap_total") = 0;
@ -803,6 +804,14 @@ namespace Mem {
std::error_code ec;
diskread >> dev >> mountpoint >> fstype;
//? If running snapped, remove internal / mountpoint and replace /mnt with / to get correct device
if (snapped) {
if (mountpoint == "/")
continue;
else if (mountpoint == "/mnt")
mountpoint = "/";
}
//? Match filter if not empty
if (not filter.empty()) {
bool match = v_contains(filter, mountpoint);