[gvfs] udisks2: set should_automount to TRUE for loop devices set up by the user
- From: David Zeuthen <davidz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] udisks2: set should_automount to TRUE for loop devices set up by the user
- Date: Thu, 26 Jul 2012 17:08:01 +0000 (UTC)
commit 88ffd85e73fec8611386530962fb35451e28571c
Author: David Zeuthen <zeuthen gmail com>
Date: Thu Jul 26 13:05:02 2012 -0400
udisks2: set should_automount to TRUE for loop devices set up by the user
Also set the Autoclear property after successfully mounting/unlocking
devices on a loop device.
Signed-off-by: David Zeuthen <zeuthen gmail com>
monitor/udisks2/gvfsudisks2volume.c | 44 +++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2volume.c b/monitor/udisks2/gvfsudisks2volume.c
index 910e1da..7bf0875 100644
--- a/monitor/udisks2/gvfsudisks2volume.c
+++ b/monitor/udisks2/gvfsudisks2volume.c
@@ -224,6 +224,10 @@ update_volume (GVfsUDisks2Volume *volume)
GVariantIter iter;
const gchar *configuration_type;
GVariant *configuration_value;
+ UDisksLoop *loop = NULL;
+
+ loop = udisks_client_get_loop_for_block (gvfs_udisks2_volume_monitor_get_udisks_client (volume->monitor),
+ volume->block);
/* If unlocked, use the values from the unlocked block device for presentation */
cleartext_block = udisks_client_get_cleartext_block (gvfs_udisks2_volume_monitor_get_udisks_client (volume->monitor),
@@ -355,6 +359,17 @@ update_volume (GVfsUDisks2Volume *volume)
g_object_unref (udisks_drive);
}
+ /* Also automount loop devices set up by the user himself - e.g. via the
+ * udisks interfaces or the gnome-disk-image-mounter(1) command
+ */
+ if (loop != NULL)
+ {
+ if (udisks_loop_get_setup_by_uid (loop) == getuid ())
+ {
+ volume->should_automount = TRUE;
+ }
+ }
+
/* Use hints, if available */
hint = udisks_block_get_hint_name (volume->block);
if (hint != NULL && strlen (hint) > 0)
@@ -402,6 +417,7 @@ update_volume (GVfsUDisks2Volume *volume)
}
g_clear_object (&cleartext_block);
+ g_clear_object (&loop);
}
else
{
@@ -886,6 +902,28 @@ mount_command_cb (GObject *source_object,
/* ------------------------------ */
static void
+ensure_autoclear (MountData *data)
+{
+ UDisksLoop *loop;
+ loop = udisks_client_get_loop_for_block (gvfs_udisks2_volume_monitor_get_udisks_client (data->volume->monitor),
+ data->volume->block);
+ if (loop != NULL)
+ {
+ if (!udisks_loop_get_autoclear (loop) && udisks_loop_get_setup_by_uid (loop) == getuid ())
+ {
+ /* we don't care about the result */
+ udisks_loop_call_set_autoclear (loop, TRUE,
+ g_variant_new ("a{sv}", NULL), /* options */
+ NULL, NULL, NULL);
+ }
+ g_object_unref (loop);
+ }
+}
+
+/* ------------------------------ */
+
+
+static void
mount_cb (GObject *source_object,
GAsyncResult *res,
gpointer user_data)
@@ -906,6 +944,9 @@ mount_cb (GObject *source_object,
}
else
{
+ /* if mounting worked, ensure that the loop device goes away when unmounted */
+ ensure_autoclear (data);
+
gvfs_udisks2_volume_monitor_update (data->volume->monitor);
g_simple_async_result_complete (data->simple);
g_free (mount_path);
@@ -1035,6 +1076,9 @@ unlock_cb (GObject *source_object,
{
UDisksObject *object;
+ /* if unlocking worked, ensure that the loop device goes away when locked */
+ ensure_autoclear (data);
+
gvfs_udisks2_volume_monitor_update (data->volume->monitor);
object = udisks_client_peek_object (gvfs_udisks2_volume_monitor_get_udisks_client (data->volume->monitor),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]