Add MDRaid:SyncAction and MDRaid:Degraded properties
authorDavid Zeuthen <zeuthen@gmail.com>
Fri, 7 Sep 2012 20:51:18 +0000 (16:51 -0400)
committerDavid Zeuthen <zeuthen@gmail.com>
Fri, 7 Sep 2012 20:51:18 +0000 (16:51 -0400)
Signed-off-by: David Zeuthen <zeuthen@gmail.com>
data/org.freedesktop.UDisks2.xml
src/udiskslinuxmdraid.c

index 6ba1b85..3110bf9 100644 (file)
     -->
     <property name="Size" type="t" access="read"/>
 
-    <!-- TODO: array state -->
+    <!-- SyncAction:
+         The current state of the array or empty if the array is not
+         running.
+
+         This property corresponds to the
+         <literal>sync_action</literal> sysfs file, 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="SyncAction" type="s" access="read"/>
+
+    <!-- Degraded:
+         Number of devices by which the array is degraded (0 if not degraded).
+
+         This property corresponds to the
+         <literal>degraded</literal> sysfs file, 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="Degraded" type="u" access="read"/>
 
     <!-- TODO: start/stop methods -->
 
index 3e697e9..1eaae35 100644 (file)
@@ -137,6 +137,8 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
   GUdevDevice *raid_device;
   GList *member_devices;
   GUdevDevice *member_device;
+  guint degraded;
+  const gchar *sync_action = "";
 
   member_devices = udisks_linux_mdraid_object_get_members (object);
   if (member_devices == NULL)
@@ -164,6 +166,14 @@ udisks_linux_mdraid_update (UDisksLinuxMDRaid       *mdraid,
   udisks_mdraid_set_num_devices (iface, num_devices);
   udisks_mdraid_set_size (iface, size);
 
+  if (raid_device != NULL)
+    {
+      degraded = g_udev_device_get_sysfs_attr_as_int (raid_device, "md/degraded");
+      sync_action = g_udev_device_get_sysfs_attr (raid_device, "md/sync_action");
+    }
+  udisks_mdraid_set_degraded (iface, degraded);
+  udisks_mdraid_set_sync_action (iface, sync_action);
+
   /* TODO: set other stuff */
 
  out: