Re: [PATCH] add -l option to gvfs-mount + crash report

nf2 <[email protected]>
Newsgroups gmane.comp.gnome.vfs.general
Message-ID <[email protected]>
nf2 wrote:
>
> This patch adds the -l (list mounts) option to gvfs-mount.
>
>   
Sorry - here is the patch:

_______________________________________________
gnome-vfs-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnome-vfs-list
gvfs-mount-l.patch (text/x-patch, 2.1 KB)
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;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.