diff options
author | rbuj <[email protected]> | 2020-11-15 17:01:23 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-11-21 13:13:46 +0100 |
commit | 144afb19d06320612768e506197cd8a22d17f563 (patch) | |
tree | 6fbad962651f70dba72e566e53fb142a02f3ebf9 | |
parent | d6a31e798a391e5a6f6a157323814c884b576491 (diff) | |
download | mate-system-monitor-144afb19d06320612768e506197cd8a22d17f563.tar.bz2 mate-system-monitor-144afb19d06320612768e506197cd8a22d17f563.tar.xz |
sysinfo: avoid adding a device more than once such as for brtfs
-rw-r--r-- | src/sysinfo.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp index 65e2e07..39d5f8c 100644 --- a/src/sysinfo.cpp +++ b/src/sysinfo.cpp @@ -355,11 +355,12 @@ namespace { void load_disk_info() { + GHashTable *devices; glibtop_mountentry *entries; glibtop_mountlist mountlist; entries = glibtop_get_mountlist(&mountlist, 0); - + devices = g_hash_table_new(g_str_hash, g_str_equal); this->free_space_bytes = 0; for (guint i = 0; i != mountlist.number; ++i) { @@ -378,11 +379,18 @@ namespace { if (string(entries[i].mountdir).find("/media/") == 0) continue; + /* avoid adding a device more than once such as for btrfs filesystem */ + if (g_hash_table_contains (devices, entries[i].devname)) + continue; + else + g_hash_table_insert (devices, entries[i].devname, entries[i].mountdir); + glibtop_fsusage usage; glibtop_get_fsusage(&usage, entries[i].mountdir); this->free_space_bytes += usage.bavail * usage.block_size; } + g_hash_table_destroy (devices); g_free(entries); } |