[gvfs] udisks2: work around Linux bug for lingering partitions of cleared loop device



commit 810c166e36489982b3b9d4905f2b89a9235cecb1
Author: David Zeuthen <zeuthen gmail com>
Date:   Thu Jul 26 12:06:24 2012 -0400

    udisks2: work around Linux bug for lingering partitions of cleared loop device
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 monitor/udisks2/gvfsudisks2volumemonitor.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index c407d84..3e28579 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -898,10 +898,27 @@ should_include_volume (GVfsUDisks2VolumeMonitor *monitor,
   loop = udisks_client_get_loop_for_block (monitor->client, block);
   if (loop != NULL)
     {
-      guint setup_by_uid = udisks_loop_get_setup_by_uid (loop);
+      GDBusObject *loop_object;
+      UDisksBlock *block_for_loop;
+      guint setup_by_uid;
+
+      setup_by_uid = udisks_loop_get_setup_by_uid (loop);
       g_object_unref (loop);
       if (setup_by_uid != 0 && setup_by_uid != getuid ())
         goto out;
+
+      /* Work-around bug in Linux where partitions of a loop
+       * device (e.g. /dev/loop0p1) are lingering even when the
+       * parent loop device (e.g. /dev/loop0) has been cleared
+       */
+      loop_object = g_dbus_interface_get_object (G_DBUS_INTERFACE (loop));
+      if (loop_object == NULL)
+        goto out;
+      block_for_loop = udisks_object_peek_block (UDISKS_OBJECT (loop_object));
+      if (block_for_loop == NULL)
+        goto out;
+      if (udisks_block_get_size (block_for_loop) == 0)
+        goto out;
     }
 # endif
 #endif



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