[gnome-control-center] info: Fix total disc size for btrfs subvolumes
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] info: Fix total disc size for btrfs subvolumes
- Date: Sat, 29 Apr 2017 12:21:42 +0000 (UTC)
commit b619f7c96a0c26dd3cb303ca731d4b7adaac8d99
Author: Ondrej Holy <oholy redhat com>
Date: Fri Feb 24 14:26:44 2017 +0100
info: Fix total disc size for btrfs subvolumes
Total disc size may be wrong if something like btrfs subvolumes are
used. Do not count multiple mounts with same device_path, because
it is probably something like btrfs subvolume. Use only the first one
in order to count the real size.
https://bugzilla.gnome.org/show_bug.cgi?id=708786
panels/info/cc-info-overview-panel.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/panels/info/cc-info-overview-panel.c b/panels/info/cc-info-overview-panel.c
index 6f7d15c..45ad548 100644
--- a/panels/info/cc-info-overview-panel.c
+++ b/panels/info/cc-info-overview-panel.c
@@ -556,8 +556,10 @@ get_primary_disc_info (CcInfoOverviewPanel *self)
{
GList *points;
GList *p;
+ GHashTable *hash;
CcInfoOverviewPanelPrivate *priv = cc_info_overview_panel_get_instance_private (self);
+ hash = g_hash_table_new (g_str_hash, g_str_equal);
points = g_unix_mount_points_get (NULL);
/* If we do not have /etc/fstab around, try /etc/mtab */
@@ -568,21 +570,29 @@ get_primary_disc_info (CcInfoOverviewPanel *self)
{
GUnixMountEntry *mount = p->data;
const char *mount_path;
+ const char *device_path;
mount_path = g_unix_mount_get_mount_path (mount);
+ device_path = g_unix_mount_get_device_path (mount);
+ /* Do not count multiple mounts with same device_path, because it is
+ * probably something like btrfs subvolume. Use only the first one in
+ * order to count the real size. */
if (gsd_should_ignore_unix_mount (mount) ||
gsd_is_removable_mount (mount) ||
g_str_has_prefix (mount_path, "/media/") ||
- g_str_has_prefix (mount_path, g_get_home_dir ()))
+ g_str_has_prefix (mount_path, g_get_home_dir ()) ||
+ g_hash_table_lookup (hash, device_path) != NULL)
{
g_unix_mount_free (mount);
continue;
}
priv->primary_mounts = g_list_prepend (priv->primary_mounts, mount);
+ g_hash_table_insert (hash, (gpointer) device_path, (gpointer) device_path);
}
g_list_free (points);
+ g_hash_table_destroy (hash);
get_primary_disc_info_start (self);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]