From: Forest Bond <forest.b...@rapidrollout.com> --- data/org.freedesktop.UDisks.Device.xml | 8 ++++++++ src/device-private.c | 11 +++++++++++ src/device-private.h | 2 ++ src/device.c | 20 ++++++++++++++++++++ tools/udisks.c | 3 +++ 5 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/data/org.freedesktop.UDisks.Device.xml b/data/org.freedesktop.UDisks.Device.xml index 8b76ccb..a7e120d 100644 --- a/data/org.freedesktop.UDisks.Device.xml +++ b/data/org.freedesktop.UDisks.Device.xml @@ -2419,6 +2419,14 @@ is greater than zero. </doc:para></doc:description></doc:doc> </property> + <property name="DriveAtaSmartTemperature" type="t" access="read"> + <doc:doc><doc:description><doc:para> + The temperature for the disk in mKelvin. + This property is only valid if + <doc:ref type="property" to="Device:DriveAtaSmartTimeCollected">DriveAtaSmartTimeCollected</doc:ref> + is greater than zero. + </doc:para></doc:description></doc:doc> + </property> <!-- **************************************************************************************************** --> diff --git a/src/device-private.c b/src/device-private.c index 22a0d35..d92ee8b 100644 --- a/src/device-private.c +++ b/src/device-private.c @@ -1401,6 +1401,17 @@ device_set_drive_ata_smart_blob_steal (Device *device, emit_changed (device, "drive_ata_smart_blob"); } +void +device_set_drive_ata_smart_temperature (Device *device, + uint64_t value) +{ + if (device->priv->drive_ata_smart_temperature != value) + { + device->priv->drive_ata_smart_temperature = value; + emit_changed (device, "drive_ata_smart_temperature"); + } +} + void device_set_linux_lvm2_lv_name (Device *device, diff --git a/src/device-private.h b/src/device-private.h index a6db7f2..5621179 100644 --- a/src/device-private.h +++ b/src/device-private.h @@ -227,6 +227,7 @@ struct DevicePrivate SkSmartOverall drive_ata_smart_status; void *drive_ata_smart_blob; gsize drive_ata_smart_blob_size; + uint64_t drive_ata_smart_temperature; gchar *linux_dmmp_component_holder; @@ -392,6 +393,7 @@ void device_set_holders_objpath (Device *device, GStrv value); void device_set_drive_ata_smart_is_available (Device *device, gboolean value); void device_set_drive_ata_smart_time_collected (Device *device, guint64 value); void device_set_drive_ata_smart_status (Device *device, SkSmartOverall value); +void device_set_drive_ata_smart_temperature (Device *device, uint64_t value); void device_set_drive_ata_smart_blob_steal (Device *device, gchar *blob, gsize blob_size); G_END_DECLS diff --git a/src/device.c b/src/device.c index 91c6cd1..edb21d7 100644 --- a/src/device.c +++ b/src/device.c @@ -275,6 +275,7 @@ enum PROP_DRIVE_ATA_SMART_TIME_COLLECTED, PROP_DRIVE_ATA_SMART_STATUS, PROP_DRIVE_ATA_SMART_BLOB, + PROP_DRIVE_ATA_SMART_TEMPERATURE, PROP_LINUX_MD_COMPONENT_LEVEL, PROP_LINUX_MD_COMPONENT_POSITION, @@ -680,6 +681,9 @@ get_property (GObject *object, g_array_unref (a); } break; + case PROP_DRIVE_ATA_SMART_TEMPERATURE: + g_value_set_uint64 (value, device->priv->drive_ata_smart_temperature); + break; case PROP_LINUX_MD_COMPONENT_LEVEL: g_value_set_string (value, device->priv->linux_md_component_level); @@ -1444,6 +1448,15 @@ device_class_init (DeviceClass *klass) NULL, dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), G_PARAM_READABLE)); + g_object_class_install_property (object_class, + PROP_DRIVE_ATA_SMART_TEMPERATURE, + g_param_spec_uint64 ("drive-ata-smart-temperature", + NULL, + NULL, + 0, + G_MAXUINT64, + 0, + G_PARAM_READABLE)); g_object_class_install_property (object_class, PROP_LINUX_MD_COMPONENT_LEVEL, @@ -9666,6 +9679,7 @@ drive_ata_smart_refresh_data_completed_cb (DBusGMethodInvocation *context, gsize blob_size; time_t time_collected; SkSmartOverall overall; + uint64_t temperature; PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) start", device->priv->native_path); @@ -9758,8 +9772,14 @@ drive_ata_smart_refresh_data_completed_cb (DBusGMethodInvocation *context, PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) overall smart status", device->priv->native_path); if (sk_disk_smart_get_overall (d, &overall) != 0) overall = -1; + + PROFILE ("drive_ata_smart_refresh_data_completed_cb(device=%s) temperature", device->priv->native_path); + if (sk_disk_smart_get_temperature (d, &temperature) != 0) + temperature = 0; + device_set_drive_ata_smart_status (device, overall); device_set_drive_ata_smart_blob_steal (device, blob, blob_size); + device_set_drive_ata_smart_temperature (device, temperature); blob = NULL; /* emit change event since we've updated the smart data */ diff --git a/tools/udisks.c b/tools/udisks.c index 6481efb..007fe9c 100644 --- a/tools/udisks.c +++ b/tools/udisks.c @@ -413,6 +413,7 @@ typedef struct gchar *drive_ata_smart_status; gchar *drive_ata_smart_blob; gsize drive_ata_smart_blob_size; + guint64 drive_ata_smart_temperature; char *linux_md_component_level; int linux_md_component_position; @@ -689,6 +690,8 @@ collect_props (const char *key, props->drive_ata_smart_blob = g_memdup (a->data, a->len); props->drive_ata_smart_blob_size = a->len; } + else if (strcmp (key, "DriveAtaSmartTemperature") == 0) + props->drive_ata_smart_temperature = g_value_get_uint64 (value); else if (strcmp (key, "LinuxMdComponentLevel") == 0) props->linux_md_component_level = g_strdup (g_value_get_string (value)); -- 1.7.0.4
signature.asc
Description: Digital signature
_______________________________________________ devkit-devel mailing list devkit-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/devkit-devel