f53a007
--- trunk/programs/gvfs-mount.c	2008/04/02 19:51:01	1720
f53a007
+++ trunk/programs/gvfs-mount.c	2008/04/07 19:50:52	1726
f53a007
@@ -43,11 +43,13 @@
f53a007
 static gboolean mount_unmount = FALSE;
f53a007
 static gboolean mount_list = FALSE;
f53a007
 static gboolean mount_list_info = FALSE;
f53a007
+static const char *unmount_scheme = NULL;
f53a007
 
f53a007
-static GOptionEntry entries[] = 
f53a007
+static const GOptionEntry entries[] = 
f53a007
 {
f53a007
   { "mountable", 'm', 0, G_OPTION_ARG_NONE, &mount_mountable, "Mount as mountable", NULL },
f53a007
   { "unmount", 'u', 0, G_OPTION_ARG_NONE, &mount_unmount, "Unmount", NULL},
f53a007
+  { "unmount-scheme", 's', 0, G_OPTION_ARG_STRING, &unmount_scheme, "Unmount all mounts with the given scheme", NULL},
f53a007
   { "list", 'l', 0, G_OPTION_ARG_NONE, &mount_list, "List", NULL},
f53a007
   { "list-info", 'i', 0, G_OPTION_ARG_NONE, &mount_list_info, "List extra information", NULL},
f53a007
   { NULL }
f53a007
@@ -502,6 +504,34 @@
f53a007
   g_list_free (mounts);
f53a007
 }
f53a007
 
f53a007
+static void
f53a007
+unmount_all_with_scheme (const char *scheme)
f53a007
+{
f53a007
+  GVolumeMonitor *volume_monitor;
f53a007
+  GList *mounts;
f53a007
+  GList *l;
f53a007
+
f53a007
+  volume_monitor = g_volume_monitor_get();
f53a007
+
f53a007
+  /* populate gvfs network mounts */
f53a007
+  iterate_gmain();
f53a007
+
f53a007
+  mounts = g_volume_monitor_get_mounts (volume_monitor);
f53a007
+  for (l = mounts; l != NULL; l = l->next) {
f53a007
+    GMount *mount = G_MOUNT (l->data);
f53a007
+    GFile *root;
f53a007
+
f53a007
+    root = g_mount_get_root (mount);
f53a007
+    if (g_file_has_uri_scheme (root, scheme)) {
f53a007
+            unmount (root);
f53a007
+    }
f53a007
+    g_object_unref (root);
f53a007
+  }
f53a007
+  g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
f53a007
+  g_list_free (mounts);
f53a007
+
f53a007
+}
f53a007
+
f53a007
 int
f53a007
 main (int argc, char *argv[])
f53a007
 {
f53a007
@@ -523,6 +553,10 @@
f53a007
   
f53a007
   if (mount_list)
f53a007
     list_monitor_items ();
f53a007
+  else if (unmount_scheme != NULL)
f53a007
+    {
f53a007
+      unmount_all_with_scheme (unmount_scheme);
f53a007
+    }
f53a007
   else if (argc > 1)
f53a007
     {
f53a007
       int i;