Bugzilla – Attachment 175846 Details for
Bug 152846
Hard drive free space in main-menu is wrong
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
IDP Log In
|
Forgot Password
[patch]
gnome-main-menu-152846-hard-drive-free-space.diff
gnome-main-menu-152846-hard-drive-free-space.diff (text/plain), 5.09 KB, created by
Federico Mena Quintero
on 2007-10-01 20:15:01 UTC
(
hide
)
Description:
gnome-main-menu-152846-hard-drive-free-space.diff
Filename:
MIME Type:
Creator:
Federico Mena Quintero
Created:
2007-10-01 20:15:01 UTC
Size:
5.09 KB
patch
obsolete
>2007-10-01 Federico Mena Quintero <federico@novell.com> > > Fix https://bugzilla.novell.com/show_bug.cgi?id=152846 - Hard > drive free space is wrong for LVM volumes. > > The rationale is that we want to show the free space for your home > directory, since that's the only place where you can write data, > anyway. As an exercise for the reader, this could be improved to > support disk quotas and other things that may reduce the amount of > space to which you can write. > > * main-menu/src/hard-drive-status-tile.c (compute_usage): Use > statvfs() to get info for the user's home directory, instead of a > combination of libhal / glibtop. > (get_pertinent_devices): Removed. > (hard_drive_status_tile_init): No need to initialize dbus/hal. > >diff --git a/main-menu/src/hard-drive-status-tile.c b/main-menu/src/hard-drive-status-tile.c >index 3ca3de2..cf698f3 100644 >--- a/main-menu/src/hard-drive-status-tile.c >+++ b/main-menu/src/hard-drive-status-tile.c >@@ -21,13 +21,8 @@ > #include "hard-drive-status-tile.h" > > #include <string.h> >-#include <dbus/dbus.h> >-#include <dbus/dbus-glib.h> >-#include <dbus/dbus-glib-lowlevel.h> >+#include <sys/statvfs.h> > #include <glib/gi18n.h> >-#include <glibtop/fsusage.h> >-#include <libhal.h> >-#include <libhal-storage.h> > #include <gconf/gconf-client.h> > > #include "slab-gnome-util.h" >@@ -59,9 +54,6 @@ static void tile_show_event_cb (GtkWidget *, gpointer); > > typedef struct > { >- LibHalContext *hal_context; >- DBusConnection *dbus_connection; >- > GConfClient *gconf; > > guint64 capacity_bytes; >@@ -148,51 +140,6 @@ static void > hard_drive_status_tile_init (HardDriveStatusTile * tile) > { > HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (tile); >- DBusError error; >- >- priv->hal_context = libhal_ctx_new (); >- >- if (!priv->hal_context) >- return; >- >- dbus_error_init (&error); >- priv->dbus_connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); >- >- dbus_connection_set_exit_on_disconnect (priv->dbus_connection, FALSE); >- >- if (dbus_error_is_set (&error)) >- { >- g_warning ("error (%s): [%s]\n", error.name, error.message); >- >- dbus_error_free (&error); >- >- priv->hal_context = NULL; >- priv->dbus_connection = NULL; >- >- return; >- } >- >- dbus_error_free (&error); >- >- dbus_connection_setup_with_g_main (priv->dbus_connection, g_main_context_default ()); >- >- libhal_ctx_set_dbus_connection (priv->hal_context, priv->dbus_connection); >- >- dbus_error_init (&error); >- libhal_ctx_init (priv->hal_context, &error); >- >- if (dbus_error_is_set (&error)) >- { >- g_warning ("error (%s): [%s]\n", error.name, error.message); >- >- dbus_error_free (&error); >- >- priv->hal_context = NULL; >- >- return; >- } >- >- dbus_error_free (&error); > > priv->gconf = gconf_client_get_default (); > gconf_client_add_dir (priv->gconf, TIMEOUT_KEY_DIR, GCONF_CLIENT_PRELOAD_NONE, NULL); >@@ -201,8 +148,6 @@ hard_drive_status_tile_init (HardDriveStatusTile * tile) > static void > hard_drive_status_tile_finalize (GObject * g_object) > { >-/* if (data->hal_context) >- libhal_ctx_free (data->hal_context); */ > /* FIXME */ > (*G_OBJECT_CLASS (hard_drive_status_tile_parent_class)->finalize) (g_object); > } >@@ -242,90 +187,20 @@ hard_drive_status_tile_activated (Tile * tile, TileEvent * event) > tile_trigger_action_with_time (tile, tile->default_action, event->time); > } > >-static GList * >-get_pertinent_devices (LibHalContext * hal_context) >-{ >- GList *devices; >- >- gchar **udis; >- gint n_udis; >- >- LibHalVolume *vol; >- gchar *mount_point; >- >- DBusError error; >- >- gint i; >- >- if (!hal_context) >- return NULL; >- >- dbus_error_init (&error); >- udis = libhal_find_device_by_capability (hal_context, "volume", &n_udis, &error); >- >- if (dbus_error_is_set (&error)) >- { >- g_warning ("error (%s): [%s]\n", error.name, error.message); >- >- dbus_error_free (&error); >- >- return NULL; >- } >- >- dbus_error_free (&error); >- >- devices = NULL; >- >- for (i = 0; i < n_udis; ++i) >- { >- vol = libhal_volume_from_udi (hal_context, udis[i]); >- >- if (libhal_volume_is_mounted (vol) && !libhal_volume_is_disc (vol)) >- { >- mount_point = g_strdup (libhal_volume_get_mount_point (vol)); >- devices = g_list_append (devices, mount_point); >- } >- >- libhal_volume_free (vol); >- } >- >- libhal_free_string_array (udis); >- >- return devices; >-} >- > static void > compute_usage (HardDriveStatusTile * tile) > { > HardDriveStatusTilePrivate *priv = HARD_DRIVE_STATUS_TILE_GET_PRIVATE (tile); >+ struct statvfs s; > >- GList *devices; >- glibtop_fsusage fs_usage; >- >- GList *node; >- >- if (!priv->hal_context) >+ if (statvfs (g_get_home_dir (), &s) != 0) { >+ priv->available_bytes = 0; >+ priv->capacity_bytes = 0; > return; >- >- devices = get_pertinent_devices (priv->hal_context); >- >- priv->capacity_bytes = 0; >- priv->available_bytes = 0; >- >- for (node = devices; node; node = node->next) >- { >- if (node->data) >- { >- glibtop_get_fsusage (&fs_usage, (gchar *) node->data); >- >- priv->available_bytes += fs_usage.bfree * fs_usage.block_size; >- priv->capacity_bytes += fs_usage.blocks * fs_usage.block_size; >- >- g_free (node->data); >- } > } > >- g_list_free (devices); >+ priv->available_bytes = (guint64) s.f_frsize * s.f_bavail; >+ priv->capacity_bytes = (guint64) s.f_frsize * s.f_blocks; > } > > static gchar *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
Actions:
View
|
Diff
Attachments on
bug 152846
:
69830
|
79091
| 175846