Slightly change how the MDRaid:ActiveDevice property works
authorDavid Zeuthen <zeuthen@gmail.com>
Fri, 14 Sep 2012 15:03:19 +0000 (11:03 -0400)
committerDavid Zeuthen <zeuthen@gmail.com>
Fri, 14 Sep 2012 15:03:19 +0000 (11:03 -0400)
It's easier to use from applications if it's an array with a fixed
size.

Signed-off-by: David Zeuthen <zeuthen@gmail.com>
data/org.freedesktop.UDisks2.xml
src/udiskslinuxmdraid.c

index 1280918..b427d35 100644 (file)
     <property name="Degraded" type="u" access="read"/>
 
     <!-- ActiveDevices:
-         This property is a dictionary from the position of the member device
-         in question (0, 1, 2, up to but not including #org.freedesktop.UDisks2.MDRaid:NumDevices)
-         into a struct of with the following members
+         This property is an array with #org.freedesktop.UDisks2.MDRaid:NumDevices elements if
+         the array is running, zero elements otherwise. Each element of the array is a struct
+         with the following members:
          <variablelist>
          <varlistentry><term>block (type 'o')</term>
-         <listitem><para>The object for the underlying block device - guaranteed to implement the #org.freedesktop.UDisks2.Block interface</para></listitem></varlistentry>
+         <listitem><para>If there is no member in the given position this is set to '/', otherwise it is the object path for the underlying block device (guaranteed to implement the #org.freedesktop.UDisks2.Block interface)</para></listitem></varlistentry>
          <varlistentry><term>state (type 's')</term>
-         <listitem><para>The state of the member, e.g. one of <literal>faulty</literal>, <literal>in_sync</literal>, <literal>writemostly</literal>, <literal>blocked</literal> and <literal>spare</literal></para></listitem></varlistentry>
-         <varlistentry><term>errors (type 't')</term>
-         <listitem><para>Ongoing count of read errors that have been detected on this device but have not caused the device to be evicted from the array</para></listitem></varlistentry>
+         <listitem><para>Blank if there is no member in the position, otherwise the state of the member, e.g. one of <literal>faulty</literal>, <literal>in_sync</literal>, <literal>writemostly</literal>, <literal>blocked</literal> and <literal>spare</literal></para></listitem></varlistentry>
+         <varlistentry><term>num_read_errors (type 't')</term>
+         <listitem><para>Zero if there is no member in the position in question, otherwise an ongoing count of read errors that have been detected on this device but have not caused the device to be evicted from the array</para></listitem></varlistentry>
          <varlistentry><term>expansion (type 'a{sv}')</term>
          <listitem><para>Currently unused. Intended for future expansion.</para></listitem></varlistentry>
          </variablelist>
-
-         This property and its struct members corresponds to the
+         This property correspond to the
          <literal>rdNN</literal> symlinks in sysfs and the sysfs files in each directory.
          See the
          <filename><ulink url="http://www.kernel.org/doc/Documentation/md.txt">Documentation/md.txt</ulink></filename>
          file shipped with the kernel sources.
     -->
-    <property name="ActiveDevices" type="a{u(osta{sv})}" access="read"/>
+    <property name="ActiveDevices" type="a(osta{sv})" access="read"/>
 
     <!--
         Start:
index 158ff0a..155857b 100644 (file)
@@ -337,7 +337,7 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
     }
 
   /* figure out active devices */
-  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a{u(osta{sv})}"));
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(osta{sv})"));
   if (raid_device != NULL)
     {
       const gchar *raid_sysfs_path = g_udev_device_get_sysfs_path (raid_device);
@@ -357,7 +357,9 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
             {
               udisks_warning ("Unable to resolve %s/%s symlink",
                               raid_sysfs_path, p);
-              goto skip_member;
+              g_variant_builder_add (&builder, "(osta{sv})",
+                                     "/", "", 0, NULL);
+              goto member_done;
             }
 
           member_object = udisks_daemon_find_block_by_sysfs_path (daemon, block_sysfs_path);
@@ -365,7 +367,9 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
             {
               /* TODO: only warn on !coldplug */
               /* udisks_warning ("No object for block device with sysfs path %s", block_sysfs_path); */
-              goto skip_member;
+              g_variant_builder_add (&builder, "(osta{sv})",
+                                     "/", "", 0, NULL);
+              goto member_done;
             }
 
           snprintf (p, sizeof (p), "md/rd%d/state", n);
@@ -376,14 +380,13 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
           snprintf (p, sizeof (p), "md/rd%d/errors", n);
           member_errors = read_sysfs_attr_as_uint64 (raid_device, p);
 
-          g_variant_builder_add (&builder, "{u(osta{sv})}",
-                                 n,
+          g_variant_builder_add (&builder, "(osta{sv})",
                                  g_dbus_object_get_object_path (G_DBUS_OBJECT (member_object)),
                                  member_state,
                                  member_errors,
                                  NULL); /* expansion, unused for now */
 
-        skip_member:
+        member_done:
           g_clear_object (&member_object);
           g_free (block_sysfs_path);
         }