mate-system-monitor/1008-sysinfo-avoid-adding-a-device-more-than-once-such-as-9e756f14.patch
2022-08-04 10:37:58 +08:00

51 lines
1.6 KiB
Diff

From 9e756f149a2c06dfcd37505b4fd35b6b64f77ab8 Mon Sep 17 00:00:00 2001
From: rbuj <robert.buj@gmail.com>
Date: Sun, 15 Nov 2020 17:01:23 +0100
Subject: [PATCH] sysinfo: avoid adding a device more than once such as for
brtfs
---
src/sysinfo.cpp | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/sysinfo.cpp b/src/sysinfo.cpp
index 4ef988e..0db9cc8 100644
--- a/src/sysinfo.cpp
+++ b/src/sysinfo.cpp
@@ -271,11 +271,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) {
@@ -294,11 +295,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);
}
--
2.27.0