summaryrefslogtreecommitdiff
path: root/programs
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2008-04-07 19:50:52 +0000
committerDavid Zeuthen <davidz@src.gnome.org>2008-04-07 19:50:52 +0000
commit1fd7ffcff3362be48b47c48a6d0ea559cffa0f26 (patch)
treeed90f4facb02a71e0f5f54736e1cfb7b0fd97a6d /programs
parenteb9358c2032ceaec38a10fd122716a5f3bda7304 (diff)
downloadgvfs-1fd7ffcff3362be48b47c48a6d0ea559cffa0f26.tar.gz
Unbreak the gphoto2 backend by allowing automounting.
2008-04-07 David Zeuthen <davidz@redhat.com> * hal/ghalvolume.c (g_hal_volume_new): Unbreak the gphoto2 backend by allowing automounting. * programs/gvfs-mount.c (main, unmount_all_with_scheme): Add a new option --unmount-scheme * AUTHORS: Add cdda and gphoto2 backends svn path=/trunk/; revision=1726
Diffstat (limited to 'programs')
-rw-r--r--programs/gvfs-mount.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c
index 83daad66..65e2ac49 100644
--- a/programs/gvfs-mount.c
+++ b/programs/gvfs-mount.c
@@ -43,11 +43,13 @@ static gboolean mount_mountable = FALSE;
static gboolean mount_unmount = FALSE;
static gboolean mount_list = FALSE;
static gboolean mount_list_info = FALSE;
+static const char *unmount_scheme = NULL;
-static GOptionEntry entries[] =
+static const 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-scheme", 's', 0, G_OPTION_ARG_STRING, &unmount_scheme, "Unmount all mounts with the given scheme", NULL},
{ "list", 'l', 0, G_OPTION_ARG_NONE, &mount_list, "List", NULL},
{ "list-info", 'i', 0, G_OPTION_ARG_NONE, &mount_list_info, "List extra information", NULL},
{ NULL }
@@ -502,6 +504,34 @@ list_monitor_items(void)
g_list_free (mounts);
}
+static void
+unmount_all_with_scheme (const char *scheme)
+{
+ GVolumeMonitor *volume_monitor;
+ GList *mounts;
+ GList *l;
+
+ volume_monitor = g_volume_monitor_get();
+
+ /* populate gvfs network mounts */
+ iterate_gmain();
+
+ mounts = g_volume_monitor_get_mounts (volume_monitor);
+ for (l = mounts; l != NULL; l = l->next) {
+ GMount *mount = G_MOUNT (l->data);
+ GFile *root;
+
+ root = g_mount_get_root (mount);
+ if (g_file_has_uri_scheme (root, scheme)) {
+ unmount (root);
+ }
+ g_object_unref (root);
+ }
+ g_list_foreach (mounts, (GFunc)g_object_unref, NULL);
+ g_list_free (mounts);
+
+}
+
int
main (int argc, char *argv[])
{
@@ -523,6 +553,10 @@ main (int argc, char *argv[])
if (mount_list)
list_monitor_items ();
+ else if (unmount_scheme != NULL)
+ {
+ unmount_all_with_scheme (unmount_scheme);
+ }
else if (argc > 1)
{
int i;