Re: [PATCH] add -l option to gvfs-mount + crash report
- From: nf2 <nf2 scheinwelt at>
- To: "gnome-vfs-list gnome org" <gnome-vfs-list gnome org>
- Subject: Re: [PATCH] add -l option to gvfs-mount + crash report
- Date: Wed, 09 Jan 2008 18:30:35 +0100
nf2 wrote:
This patch adds the -l (list mounts) option to gvfs-mount.
Sorry - here is the patch:
Index: programs/gvfs-mount.c
===================================================================
--- programs/gvfs-mount.c (revision 1085)
+++ programs/gvfs-mount.c (working copy)
@@ -35,11 +35,13 @@
static gboolean mount_mountable = FALSE;
static gboolean mount_unmount = FALSE;
+static gboolean mount_list_mounts = FALSE;
static GOptionEntry entries[] =
{
{ "mountable", 'm', 0, G_OPTION_ARG_NONE, &mount_mountable, "Mount as mountable", NULL },
- { "unmount", 'u', 0, G_OPTION_ARG_NONE, &mount_unmount, "Unmount", NULL},
+ { "unmount", 'u', 0, G_OPTION_ARG_NONE, &mount_unmount, "Unmount", NULL},
+ { "list-mounts", 'l', 0, G_OPTION_ARG_NONE, &mount_list_mounts, "List Mounts", NULL},
{ NULL }
};
@@ -212,6 +214,58 @@
outstanding_mounts++;
}
+// =============== list mounts ==================
+
+static GMainLoop *main_loop;
+
+static gboolean iterate_gmain_timeout_function(gpointer data)
+{
+ g_main_loop_quit (main_loop);
+ return FALSE;
+}
+
+static void iterate_gmain()
+{
+
+ g_timeout_add(500, iterate_gmain_timeout_function, NULL);
+
+ main_loop = g_main_loop_new (NULL, FALSE);
+ g_main_loop_run (main_loop);
+ g_main_loop_unref(main_loop);
+}
+
+static void list_mounts()
+{
+ GVolumeMonitor* gVolumeMonitor = g_volume_monitor_get();
+
+ // populate gvfs network mounts
+ iterate_gmain();
+
+ {
+ GList* mountList = g_volume_monitor_get_mounts(gVolumeMonitor);
+ GList* el2 = mountList;
+
+ while(el2)
+ {
+ GMount * gMount = (GMount *) el2->data;
+
+ char * mountName = g_mount_get_name(gMount);
+ GFile * gFileRoot = g_mount_get_root(gMount);
+
+ char * pointsToUri = g_file_get_uri(gFileRoot);
+
+ printf("mountName=%s rootUri=%s\n", mountName, pointsToUri);
+
+ g_object_unref(gFileRoot);
+ g_free(mountName);
+ g_free(pointsToUri);
+
+ el2 = g_list_next(el2);
+ }
+ }
+}
+
+
int
main (int argc, char *argv[])
{
@@ -229,6 +283,9 @@
g_option_context_parse (context, &argc, &argv, &error);
g_option_context_free (context);
+ if (mount_list_mounts)
+ list_mounts();
+ else
if (argc > 1)
{
int i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]