[gnome-disk-utility] disk-image-mounter: use Loop.SetAutoclear() and treat error as non-fatal



commit 01973ca0b9858314be668c38c461c4d36b6a7457
Author: David Zeuthen <davidz redhat com>
Date:   Fri May 4 12:06:18 2012 -0400

    disk-image-mounter: use Loop.SetAutoclear() and treat error as non-fatal
    
    Do this instead of using loop.autoclear in Filesystem.Mount().
    
    Need to do this because if the disk image is on a GVfs mount, then the
    FUSE crap may not allow uid 0 (udisksd) to do the LO_GET_STATUS64 ioctl
    on the loop device. Annoying.
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/disk-image-mounter/main.c |   22 +++++++++++++++++++---
 1 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/src/disk-image-mounter/main.c b/src/disk-image-mounter/main.c
index 4cfb990..ba0fe72 100644
--- a/src/disk-image-mounter/main.c
+++ b/src/disk-image-mounter/main.c
@@ -291,11 +291,9 @@ main (int argc, char *argv[])
           goto out;
         }
 
-      g_variant_builder_init (&options_builder, G_VARIANT_TYPE_VARDICT);
-      g_variant_builder_add (&options_builder, "{sv}", "loop.autoclear", g_variant_new_boolean (TRUE));
       error = NULL;
       if (!udisks_filesystem_call_mount_sync (filesystem,
-                                              g_variant_builder_end (&options_builder),
+                                              g_variant_new ("a{sv}", NULL), /* options */
                                               NULL, /* out_mount_path */
                                               NULL, /* cancellable */
                                               &error))
@@ -318,6 +316,24 @@ main (int argc, char *argv[])
           goto out;
         }
 
+      /* Finally set autoclear to TRUE so the loop device will get removed
+       * when the filesystem is unmounted
+       */
+      error = NULL;
+      if (!udisks_loop_call_set_autoclear_sync (loop,
+                                                TRUE,
+                                                g_variant_new ("a{sv}", NULL), /* options */
+                                                NULL, /* cancellable */
+                                                &error))
+        {
+          /* this is not fatal but can happen when using FUSE crap where uid 0 is
+           * not permitted to view files on a FUSE mount
+           */
+          g_printerr (_("Non-fatal error: error setting autoclear to TRUE: %s (%s, %d)\n"),
+                      error->message, g_quark_to_string (error->domain), error->code);
+          g_error_free (error);
+        }
+
       g_free (filename);
     }
 



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