summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-11-15 17:01:23 +0100
committerraveit65 <[email protected]>2020-11-21 12:02:03 +0100
commitcd2d9c2d5bbca35d089ff4ca5171a9da95efb09f (patch)
tree2d716e29c4d80ecd89d6257182961cfec2bdf79f
parent58e338e80ac0e611626f5b2e62a2f32a4059025a (diff)
downloadmate-system-monitor-cd2d9c2d5bbca35d089ff4ca5171a9da95efb09f.tar.bz2
mate-system-monitor-cd2d9c2d5bbca35d089ff4ca5171a9da95efb09f.tar.xz
sysinfo: avoid adding a device more than once such as for brtfs
-rw-r--r--src/sysinfo.cpp10
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);
}