static VALUE unixmountpoints_get(G_GNUC_UNUSED VALUE self) { guint64 time_read; GList *mount_points; mount_points = g_unix_mount_points_get(&time_read); return rb_assoc_new(GLIST2ARY_STR_FREE(mount_points), GUINT642RVAL(time_read)); }
static void update_volumes (GUnixVolumeMonitor *monitor) { GList *new_mountpoints; GList *removed, *added; GList *l; GUnixVolume *volume; new_mountpoints = g_unix_mount_points_get (NULL); new_mountpoints = g_list_sort (new_mountpoints, (GCompareFunc) g_unix_mount_point_compare); diff_sorted_lists (monitor->last_mountpoints, new_mountpoints, (GCompareFunc) g_unix_mount_point_compare, &added, &removed); for (l = removed; l != NULL; l = l->next) { GUnixMountPoint *mountpoint = l->data; volume = _g_unix_volume_monitor_lookup_volume_for_mount_path (monitor, g_unix_mount_point_get_mount_path (mountpoint)); if (volume) { _g_unix_volume_disconnected (volume); monitor->volumes = g_list_remove (monitor->volumes, volume); g_signal_emit_by_name (monitor, "volume-removed", volume); g_signal_emit_by_name (volume, "removed"); g_object_unref (volume); } } for (l = added; l != NULL; l = l->next) { GUnixMountPoint *mountpoint = l->data; volume = _g_unix_volume_new (G_VOLUME_MONITOR (monitor), mountpoint); if (volume) { monitor->volumes = g_list_prepend (monitor->volumes, volume); g_signal_emit_by_name (monitor, "volume-added", volume); } } g_list_free (added); g_list_free (removed); g_list_foreach (monitor->last_mountpoints, (GFunc)g_unix_mount_point_free, NULL); g_list_free (monitor->last_mountpoints); monitor->last_mountpoints = new_mountpoints; }
static gboolean ldsm_check_all_mounts (gpointer data) { GList *mounts; GList *l; GList *check_mounts = NULL; GList *full_mounts = NULL; guint number_of_mounts; guint number_of_full_mounts; gboolean multiple_volumes = FALSE; gboolean other_usable_volumes = FALSE; /* We iterate through the static mounts in /etc/fstab first, seeing if * they're mounted by checking if the GUnixMountPoint has a corresponding GUnixMountEntry. * Iterating through the static mounts means we automatically ignore dynamically mounted media. */ mounts = g_unix_mount_points_get (time_read); for (l = mounts; l != NULL; l = l->next) { GUnixMountPoint *mount_point = l->data; GUnixMountEntry *mount; LdsmMountInfo *mount_info; const gchar *path; path = g_unix_mount_point_get_mount_path (mount_point); mount = g_unix_mount_at (path, time_read); g_unix_mount_point_free (mount_point); if (mount == NULL) { /* The GUnixMountPoint is not mounted */ continue; } mount_info = g_new0 (LdsmMountInfo, 1); mount_info->mount = mount; path = g_unix_mount_get_mount_path (mount); if (g_unix_mount_is_readonly (mount)) { ldsm_free_mount_info (mount_info); continue; } if (ldsm_mount_should_ignore (mount)) { ldsm_free_mount_info (mount_info); continue; } if (statvfs (path, &mount_info->buf) != 0) { ldsm_free_mount_info (mount_info); continue; } if (ldsm_mount_is_virtual (mount_info)) { ldsm_free_mount_info (mount_info); continue; } check_mounts = g_list_prepend (check_mounts, mount_info); } g_list_free (mounts); number_of_mounts = g_list_length (check_mounts); if (number_of_mounts > 1) multiple_volumes = TRUE; for (l = check_mounts; l != NULL; l = l->next) { LdsmMountInfo *mount_info = l->data; if (!ldsm_mount_has_space (mount_info)) { full_mounts = g_list_prepend (full_mounts, mount_info); } else { g_hash_table_remove (ldsm_notified_hash, g_unix_mount_get_mount_path (mount_info->mount)); ldsm_free_mount_info (mount_info); } } number_of_full_mounts = g_list_length (full_mounts); if (number_of_mounts > number_of_full_mounts) other_usable_volumes = TRUE; ldsm_maybe_warn_mounts (full_mounts, multiple_volumes, other_usable_volumes); g_list_free (check_mounts); g_list_free (full_mounts); return TRUE; }