[gvfs] gvfs-mount: allow specifying G_MOUNT_UNMOUNT_FORCE



commit 038f186fa471c1da1b5c72aaae7dca89aa098aa6
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Sep 5 17:39:37 2014 +0200

    gvfs-mount: allow specifying G_MOUNT_UNMOUNT_FORCE
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710986

 man/gvfs-mount.xml    |    6 ++++++
 programs/gvfs-mount.c |   10 ++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/man/gvfs-mount.xml b/man/gvfs-mount.xml
index fbe0543..64b7c37 100644
--- a/man/gvfs-mount.xml
+++ b/man/gvfs-mount.xml
@@ -112,6 +112,12 @@
                         </varlistentry>
 
                         <varlistentry>
+                                <term><option>-f</option>, <option>--force</option></term>
+
+                                <listitem><para>Ignore outstanding file operations when unmounting or 
ejecting.</para></listitem>
+                        </varlistentry>
+
+                        <varlistentry>
                                 <term><option>-l</option>, <option>--list</option></term>
 
                                 <listitem><para>List all known mounts.</para></listitem>
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c
index 69f24bd..96abaa2 100644
--- a/programs/gvfs-mount.c
+++ b/programs/gvfs-mount.c
@@ -45,6 +45,7 @@ static GMainLoop *main_loop;
 static gboolean mount_mountable = FALSE;
 static gboolean mount_unmount = FALSE;
 static gboolean mount_eject = FALSE;
+static gboolean force = FALSE;
 static gboolean mount_list = FALSE;
 static gboolean extra_detail = FALSE;
 static gboolean mount_monitor = FALSE;
@@ -61,6 +62,7 @@ static const GOptionEntry entries[] =
   { "unmount", 'u', 0, G_OPTION_ARG_NONE, &mount_unmount, N_("Unmount"), NULL},
   { "eject", 'e', 0, G_OPTION_ARG_NONE, &mount_eject, N_("Eject"), NULL},
   { "unmount-scheme", 's', 0, G_OPTION_ARG_STRING, &unmount_scheme, N_("Unmount all mounts with the given 
scheme"), N_("SCHEME") },
+  { "force", 'f', 0, G_OPTION_ARG_NONE, &force, N_("Ignore outstanding file operations when unmounting or 
ejecting"), NULL },
   /* Translator: List here is a verb as in 'List all mounts' */
   { "list", 'l', 0, G_OPTION_ARG_NONE, &mount_list, N_("List"), NULL},
   { "monitor", 'o', 0, G_OPTION_ARG_NONE, &mount_monitor, N_("Monitor events"), NULL},
@@ -299,6 +301,7 @@ unmount (GFile *file)
   GMount *mount;
   GError *error = NULL;
   GMountOperation *mount_op;
+  GMountUnmountFlags flags;
 
   if (file == NULL)
     return;
@@ -312,7 +315,8 @@ unmount (GFile *file)
     }
 
   mount_op = new_mount_op ();
-  g_mount_unmount_with_operation (mount, 0, mount_op, NULL, unmount_done_cb, NULL);
+  flags = force ? G_MOUNT_UNMOUNT_FORCE : G_MOUNT_UNMOUNT_NONE;
+  g_mount_unmount_with_operation (mount, flags, mount_op, NULL, unmount_done_cb, NULL);
   g_object_unref (mount_op);
 
   outstanding_mounts++;
@@ -348,6 +352,7 @@ eject (GFile *file)
   GMount *mount;
   GError *error = NULL;
   GMountOperation *mount_op;
+  GMountUnmountFlags flags;
 
   if (file == NULL)
     return;
@@ -361,7 +366,8 @@ eject (GFile *file)
     }
 
   mount_op = new_mount_op ();
-  g_mount_eject_with_operation (mount, 0, mount_op, NULL, eject_done_cb, NULL);
+  flags = force ? G_MOUNT_UNMOUNT_FORCE : G_MOUNT_UNMOUNT_NONE;
+  g_mount_eject_with_operation (mount, flags, mount_op, NULL, eject_done_cb, NULL);
   g_object_unref (mount_op);
 
   outstanding_mounts++;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]