[gnome-disk-utility] Show block device, even if size is zero



commit 11e1b2be39f0d27ec8b3d50c91c18a60f7a06d33
Author: David Zeuthen <zeuthen gmail com>
Date:   Tue Dec 18 15:24:03 2012 -0500

    Show block device, even if size is zero
    
    Why? Because under some circumstances the mdadm(8) command creates
    "inactive" devices on failure paths - for example if asked to start an
    array with a given UUID and not enough members are present, the
    created device is left behind. I think this is a bug but instead of
    second-guessing (e.g. stopping the inactive MD device), it's better to
    just show the mess so the user/administrator himself can take action.
    
    We do keep the "hide device of size zero" rule for loop devices since
    normal Linux systems - for historical reasons - have them by default.
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 src/disks/gdudevicetreemodel.c |   17 ++++++++++++++---
 1 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/disks/gdudevicetreemodel.c b/src/disks/gdudevicetreemodel.c
index ec2abef..ab3dfa0 100644
--- a/src/disks/gdudevicetreemodel.c
+++ b/src/disks/gdudevicetreemodel.c
@@ -1418,6 +1418,7 @@ should_include_block (UDisksObject *object)
 {
   UDisksBlock *block;
   UDisksPartition *partition;
+  UDisksLoop *loop;
   gboolean ret;
   const gchar *device;
   const gchar *drive;
@@ -1428,19 +1429,29 @@ should_include_block (UDisksObject *object)
 
   block = udisks_object_peek_block (object);
   partition = udisks_object_peek_partition (object);
+  loop = udisks_object_peek_loop (object);
 
   /* RAM devices are useless */
   device = udisks_block_get_device (block);
   if (g_str_has_prefix (device, "/dev/ram"))
     goto out;
 
-  /* MD-RAID devices (e.g. /dev/md0) are shown in their own section */
+  /* MD-RAID devices (e.g. /dev/md0) with an associated org.fd.UDisks.MDRaid object are
+   * shown in their own section so don't show them here
+   */
   if (g_strcmp0 (udisks_block_get_mdraid (block), "/") != 0)
     goto out;
 
-  /* Don't show devices of size zero - otherwise we'd end up showing unused loop devices */
+  /* Don't show loop devices of size zero - they're unused.
+   *
+   * Do show any other block device of size 0.
+   *
+   * Note that we _do_ want to show any other device of size 0 (for
+   * exampleinactive MD-RAID devices) since that's a good hint that
+   * the system is misconfigured and attention is needed.
+   */
   size = udisks_block_get_size (block);
-  if (size == 0)
+  if (size == 0 && loop != NULL)
     goto out;
 
   /* Only include devices if they are top-level */



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