add linux-md-home-host and linux-md-component-home-host properties
authorDavid Zeuthen <davidz@redhat.com>
Tue, 17 Feb 2009 17:23:26 +0000 (12:23 -0500)
committerDavid Zeuthen <davidz@redhat.com>
Tue, 17 Feb 2009 17:23:26 +0000 (12:23 -0500)
src/devkit-disks-device-private.h
src/devkit-disks-device.c
src/org.freedesktop.DeviceKit.Disks.Device.xml
tools/devkit-disks.c

index 3d77f2f..881b91f 100644 (file)
@@ -153,6 +153,7 @@ struct DevkitDisksDevicePrivate
                 char *linux_md_component_level;
                 int linux_md_component_num_raid_devices;
                 char *linux_md_component_uuid;
+                char *linux_md_component_home_host;
                 char *linux_md_component_name;
                 char *linux_md_component_version;
                 guint64 linux_md_component_update_time;
@@ -161,6 +162,7 @@ struct DevkitDisksDevicePrivate
                 char *linux_md_level;
                 int linux_md_num_raid_devices;
                 char *linux_md_uuid;
+                char *linux_md_home_host;
                 char *linux_md_name;
                 char *linux_md_version;
                 GPtrArray *linux_md_slaves;
index 9254dcd..dce98a1 100644 (file)
@@ -209,6 +209,7 @@ enum
         PROP_LINUX_MD_COMPONENT_LEVEL,
         PROP_LINUX_MD_COMPONENT_NUM_RAID_DEVICES,
         PROP_LINUX_MD_COMPONENT_UUID,
+        PROP_LINUX_MD_COMPONENT_HOME_HOST,
         PROP_LINUX_MD_COMPONENT_NAME,
         PROP_LINUX_MD_COMPONENT_VERSION,
         PROP_LINUX_MD_COMPONENT_UPDATE_TIME,
@@ -217,6 +218,7 @@ enum
         PROP_LINUX_MD_LEVEL,
         PROP_LINUX_MD_NUM_RAID_DEVICES,
         PROP_LINUX_MD_UUID,
+        PROP_LINUX_MD_HOME_HOST,
         PROP_LINUX_MD_NAME,
         PROP_LINUX_MD_VERSION,
         PROP_LINUX_MD_SLAVES,
@@ -530,6 +532,9 @@ get_property (GObject         *object,
        case PROP_LINUX_MD_COMPONENT_UUID:
                g_value_set_string (value, device->priv->info.linux_md_component_uuid);
                break;
+       case PROP_LINUX_MD_COMPONENT_HOME_HOST:
+               g_value_set_string (value, device->priv->info.linux_md_component_home_host);
+               break;
        case PROP_LINUX_MD_COMPONENT_NAME:
                g_value_set_string (value, device->priv->info.linux_md_component_name);
                break;
@@ -552,6 +557,9 @@ get_property (GObject         *object,
        case PROP_LINUX_MD_UUID:
                g_value_set_string (value, device->priv->info.linux_md_uuid);
                break;
+       case PROP_LINUX_MD_HOME_HOST:
+               g_value_set_string (value, device->priv->info.linux_md_home_host);
+               break;
        case PROP_LINUX_MD_NAME:
                g_value_set_string (value, device->priv->info.linux_md_name);
                break;
@@ -973,6 +981,10 @@ devkit_disks_device_class_init (DevkitDisksDeviceClass *klass)
                 g_param_spec_string ("linux-md-component-uuid", NULL, NULL, NULL, G_PARAM_READABLE));
         g_object_class_install_property (
                 object_class,
+                PROP_LINUX_MD_COMPONENT_HOME_HOST,
+                g_param_spec_string ("linux-md-component-home-host", NULL, NULL, NULL, G_PARAM_READABLE));
+        g_object_class_install_property (
+                object_class,
                 PROP_LINUX_MD_COMPONENT_NAME,
                 g_param_spec_string ("linux-md-component-name", NULL, NULL, NULL, G_PARAM_READABLE));
         g_object_class_install_property (
@@ -1002,6 +1014,10 @@ devkit_disks_device_class_init (DevkitDisksDeviceClass *klass)
                 g_param_spec_string ("linux-md-uuid", NULL, NULL, NULL, G_PARAM_READABLE));
         g_object_class_install_property (
                 object_class,
+                PROP_LINUX_MD_HOME_HOST,
+                g_param_spec_string ("linux-md-home-host", NULL, NULL, NULL, G_PARAM_READABLE));
+        g_object_class_install_property (
+                object_class,
                 PROP_LINUX_MD_NAME,
                 g_param_spec_string ("linux-md-name", NULL, NULL, NULL, G_PARAM_READABLE));
         g_object_class_install_property (
@@ -1311,11 +1327,13 @@ free_info (DevkitDisksDevice *device)
 
         g_free (device->priv->info.linux_md_component_level);
         g_free (device->priv->info.linux_md_component_uuid);
+        g_free (device->priv->info.linux_md_component_home_host);
         g_free (device->priv->info.linux_md_component_name);
         g_free (device->priv->info.linux_md_component_version);
 
         g_free (device->priv->info.linux_md_level);
         g_free (device->priv->info.linux_md_uuid);
+        g_free (device->priv->info.linux_md_home_host);
         g_free (device->priv->info.linux_md_name);
         g_free (device->priv->info.linux_md_version);
         g_ptr_array_foreach (device->priv->info.linux_md_slaves, (GFunc) g_free, NULL);
@@ -1434,9 +1452,6 @@ update_info_properties_cb (DevkitDevice *d, const char *key, const char *value,
                 }
         } else if (strcmp (key, "ID_FS_LABEL") == 0) {
                 device->priv->info.id_label   = g_strdup (value);
-                if (device->priv->info.device_is_linux_md_component) {
-                        device->priv->info.linux_md_component_name = g_strdup (value);
-                }
 
         } else if (strcmp (key, "ID_VENDOR") == 0) {
                 if (device->priv->info.device_is_drive && device->priv->info.drive_vendor == NULL)
@@ -1540,8 +1555,28 @@ update_info_properties_cb (DevkitDevice *d, const char *key, const char *value,
                 }
 
         } else if (strcmp (key, "MD_NAME") == 0) {
-                if (device->priv->info.device_is_linux_md)
-                        device->priv->info.linux_md_name = g_strdup (value);
+                gchar **tokens;
+                const gchar *home_host;
+                const gchar *name;
+
+                tokens = g_strsplit (value, ":", 2);
+
+                if (g_strv_length (tokens) == 2) {
+                        home_host = tokens[0];
+                        name = tokens[1];
+                } else {
+                        name = tokens[0];
+                }
+
+                if (device->priv->info.device_is_linux_md) {
+                        device->priv->info.linux_md_home_host = g_strdup (home_host);
+                        device->priv->info.linux_md_name = g_strdup (name);
+                } else if (device->priv->info.device_is_linux_md_component) {
+                        device->priv->info.linux_md_component_home_host = g_strdup (home_host);
+                        device->priv->info.linux_md_component_name = g_strdup (name);
+                }
+
+                g_strfreev (tokens);
 
         } else if (strcmp (key, "DKD_DM_NAME") == 0) {
 
index 87089c8..f6bcd47 100644 (file)
             is TRUE.
       </doc:para></doc:description></doc:doc>
     </property>
+    <property name="linux-md-component-home-host" type="s" access="read">
+      <doc:doc><doc:description><doc:para>
+            The home host of the array the component is part of, e.g. where it was created. Blank if the array
+            has pre-1.0 meta data.
+            This property is only valid if
+            <doc:ref type="property" to="Device:device-is-linux-md-component">device-is-linux-md-component</doc:ref>
+            is TRUE.
+      </doc:para></doc:description></doc:doc>
+    </property>
     <property name="linux-md-component-version" type="s" access="read">
       <doc:doc><doc:description><doc:para>
             The version of superblock of the component.
             is TRUE.
       </doc:para></doc:description></doc:doc>
     </property>
+    <property name="linux-md-home-host" type="s" access="read">
+      <doc:doc><doc:description><doc:para>
+            The home host of the array, e.g. where if was created. Blank if the array
+            has pre-1.0 meta data.
+            <doc:ref type="property" to="Device:device-is-linux-md">device-is-linux-md</doc:ref>
+            is TRUE.
+      </doc:para></doc:description></doc:doc>
+    </property>
     <property name="linux-md-name" type="s" access="read">
       <doc:doc><doc:description><doc:para>
             The name of the array. Blank if the array
index ebd82b6..462911c 100644 (file)
@@ -487,6 +487,7 @@ typedef struct
         char    *linux_md_component_level;
         int      linux_md_component_num_raid_devices;
         char    *linux_md_component_uuid;
+        char    *linux_md_component_home_host;
         char    *linux_md_component_name;
         char    *linux_md_component_version;
         guint64  linux_md_component_update_time;
@@ -495,6 +496,7 @@ typedef struct
         char    *linux_md_level;
         int      linux_md_num_raid_devices;
         char    *linux_md_uuid;
+        char    *linux_md_home_host;
         char    *linux_md_name;
         char    *linux_md_version;
         char   **linux_md_slaves;
@@ -693,6 +695,8 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props)
                 props->linux_md_component_num_raid_devices = g_value_get_int (value);
         else if (strcmp (key, "linux-md-component-uuid") == 0)
                 props->linux_md_component_uuid = g_strdup (g_value_get_string (value));
+        else if (strcmp (key, "linux-md-component-home-host") == 0)
+                props->linux_md_component_home_host = g_strdup (g_value_get_string (value));
         else if (strcmp (key, "linux-md-component-name") == 0)
                 props->linux_md_component_name = g_strdup (g_value_get_string (value));
         else if (strcmp (key, "linux-md-component-version") == 0)
@@ -708,6 +712,8 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props)
                 props->linux_md_num_raid_devices = g_value_get_int (value);
         else if (strcmp (key, "linux-md-uuid") == 0)
                 props->linux_md_uuid = g_strdup (g_value_get_string (value));
+        else if (strcmp (key, "linux-md-home-host") == 0)
+                props->linux_md_home_host = g_strdup (g_value_get_string (value));
         else if (strcmp (key, "linux-md-name") == 0)
                 props->linux_md_name = g_strdup (g_value_get_string (value));
         else if (strcmp (key, "linux-md-version") == 0)
@@ -777,10 +783,12 @@ device_properties_free (DeviceProperties *props)
         g_value_unset (&(props->drive_smart_attributes));
         g_free (props->linux_md_component_level);
         g_free (props->linux_md_component_uuid);
+        g_free (props->linux_md_component_home_host);
         g_free (props->linux_md_component_name);
         g_free (props->linux_md_component_version);
         g_free (props->linux_md_level);
         g_free (props->linux_md_uuid);
+        g_free (props->linux_md_home_host);
         g_free (props->linux_md_name);
         g_free (props->linux_md_version);
         g_strfreev (props->linux_md_slaves);
@@ -910,6 +918,7 @@ do_show_info (const char *object_path)
                 g_print ("    RAID level:    %s\n", props->linux_md_component_level);
                 g_print ("    num comp:      %d\n", props->linux_md_component_num_raid_devices);
                 g_print ("    uuid:          %s\n", props->linux_md_component_uuid);
+                g_print ("    home host:     %s\n", props->linux_md_component_home_host);
                 g_print ("    name:          %s\n", props->linux_md_component_name);
                 g_print ("    version:       %s\n", props->linux_md_component_version);
                 g_print ("    update time: %" G_GUINT64_FORMAT " (%s)\n", props->linux_md_component_update_time, time_buf);
@@ -919,6 +928,7 @@ do_show_info (const char *object_path)
                 g_print ("  linux md:\n");
                 g_print ("    RAID level:    %s\n", props->linux_md_level);
                 g_print ("    uuid:          %s\n", props->linux_md_uuid);
+                g_print ("    home host:     %s\n", props->linux_md_home_host);
                 g_print ("    name:          %s\n", props->linux_md_name);
                 g_print ("    num comp:      %d\n", props->linux_md_num_raid_devices);
                 g_print ("    version:       %s\n", props->linux_md_version);