summaryrefslogtreecommitdiffstats
path: root/src/gdu
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2009-03-23 19:15:42 -0400
committerDavid Zeuthen <davidz@redhat.com>2009-03-23 19:15:42 -0400
commit74b935d6ac6a2b856ba30ed320ccee15ff3acc3a (patch)
tree2979539c4420a3049632147bdd0e6f98f39f6687 /src/gdu
parentee76b581d35b2479239706325d6599e92c35a00e (diff)
downloadgnome-disk-utility-74b935d6ac6a2b856ba30ed320ccee15ff3acc3a.tar.gz
gnome-disk-utility-74b935d6ac6a2b856ba30ed320ccee15ff3acc3a.tar.xz
gnome-disk-utility-74b935d6ac6a2b856ba30ed320ccee15ff3acc3a.zip
port to new DeviceKit-disks that uses libatasmart
Diffstat (limited to 'src/gdu')
-rw-r--r--src/gdu/Makefile.am8
-rw-r--r--src/gdu/gdu-ata-smart-attribute.c (renamed from src/gdu/gdu-smart-data-attribute.c)223
-rw-r--r--src/gdu/gdu-ata-smart-attribute.h86
-rw-r--r--src/gdu/gdu-ata-smart-historical-data.c181
-rw-r--r--src/gdu/gdu-ata-smart-historical-data.h72
-rw-r--r--src/gdu/gdu-callbacks.h24
-rw-r--r--src/gdu/gdu-device.c361
-rw-r--r--src/gdu/gdu-device.h70
-rw-r--r--src/gdu/gdu-private.h51
-rw-r--r--src/gdu/gdu-smart-data-attribute.h71
-rw-r--r--src/gdu/gdu-smart-data.c231
-rw-r--r--src/gdu/gdu-smart-data.h72
-rw-r--r--src/gdu/gdu-types.h24
-rw-r--r--src/gdu/gdu.h4
14 files changed, 851 insertions, 627 deletions
diff --git a/src/gdu/Makefile.am b/src/gdu/Makefile.am
index e970c2a..7bd608e 100644
--- a/src/gdu/Makefile.am
+++ b/src/gdu/Makefile.am
@@ -32,8 +32,8 @@ libgduinclude_HEADERS = \
gdu-pool.h \
gdu-presentable.h \
gdu-process.h \
- gdu-smart-data-attribute.h \
- gdu-smart-data.h \
+ gdu-ata-smart-attribute.h \
+ gdu-ata-smart-historical-data.h \
gdu-util.h \
gdu-volume.h \
gdu-volume-hole.h
@@ -44,8 +44,8 @@ libgdu_la_SOURCES = \
gdu-callbacks.h \
gdu-util.h gdu-util.c \
gdu-pool.c gdu-pool.h \
- gdu-smart-data.c gdu-smart-data.h \
- gdu-smart-data-attribute.c gdu-smart-data-attribute.h \
+ gdu-ata-smart-historical-data.c gdu-ata-smart-historical-data.h \
+ gdu-ata-smart-attribute.c gdu-ata-smart-attribute.h \
gdu-device.c gdu-device.h \
gdu-drive.c gdu-drive.h \
gdu-linux-md-drive.c gdu-linux-md-drive.h \
diff --git a/src/gdu/gdu-smart-data-attribute.c b/src/gdu/gdu-ata-smart-attribute.c
index 4415267..0f16013 100644
--- a/src/gdu/gdu-smart-data-attribute.c
+++ b/src/gdu/gdu-ata-smart-attribute.c
@@ -1,5 +1,5 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* gdu-smart-data-attribute.c
+/* gdu-ata-smart-attribute.c
*
* Copyright (C) 2007 David Zeuthen
*
@@ -27,102 +27,151 @@
#include <time.h>
#include "gdu-private.h"
-#include "gdu-smart-data-attribute.h"
-
-struct _GduSmartDataAttributePrivate {
- /* TODO: use guint8 */
- int id;
- int value;
- int worst;
- int threshold;
- int flags;
- char *raw;
- char *name;
+#include "gdu-ata-smart-attribute.h"
+
+struct _GduAtaSmartAttributePrivate {
+ guint id;
+ gchar *name;
+ guint flags;
+ gboolean online, prefailure;
+ guchar current;
+ gboolean current_valid;
+ guchar worst;
+ gboolean worst_valid;
+ guchar threshold;
+ gboolean threshold_valid;
+ gboolean good, good_valid;
+ guint pretty_unit;
+ guint64 pretty_value;
};
static GObjectClass *parent_class = NULL;
-G_DEFINE_TYPE (GduSmartDataAttribute, gdu_smart_data_attribute, G_TYPE_OBJECT);
+G_DEFINE_TYPE (GduAtaSmartAttribute, gdu_ata_smart_attribute, G_TYPE_OBJECT);
static void
-gdu_smart_data_attribute_finalize (GduSmartDataAttribute *smart_data_attribute)
+gdu_ata_smart_attribute_finalize (GduAtaSmartAttribute *attribute)
{
- g_free (smart_data_attribute->priv->raw);
- g_free (smart_data_attribute->priv->name);
+ g_free (attribute->priv->name);
if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (G_OBJECT (smart_data_attribute));
+ (* G_OBJECT_CLASS (parent_class)->finalize) (G_OBJECT (attribute));
}
static void
-gdu_smart_data_attribute_class_init (GduSmartDataAttributeClass *klass)
+gdu_ata_smart_attribute_class_init (GduAtaSmartAttributeClass *klass)
{
GObjectClass *obj_class = (GObjectClass *) klass;
parent_class = g_type_class_peek_parent (klass);
- obj_class->finalize = (GObjectFinalizeFunc) gdu_smart_data_attribute_finalize;
+ obj_class->finalize = (GObjectFinalizeFunc) gdu_ata_smart_attribute_finalize;
- g_type_class_add_private (klass, sizeof (GduSmartDataAttributePrivate));
+ g_type_class_add_private (klass, sizeof (GduAtaSmartAttributePrivate));
}
static void
-gdu_smart_data_attribute_init (GduSmartDataAttribute *smart_data_attribute)
+gdu_ata_smart_attribute_init (GduAtaSmartAttribute *attribute)
{
- smart_data_attribute->priv = G_TYPE_INSTANCE_GET_PRIVATE (smart_data_attribute, GDU_TYPE_SMART_DATA_ATTRIBUTE, GduSmartDataAttributePrivate);
+ attribute->priv = G_TYPE_INSTANCE_GET_PRIVATE (attribute, GDU_TYPE_ATA_SMART_ATTRIBUTE, GduAtaSmartAttributePrivate);
}
-int
-gdu_smart_data_attribute_get_id (GduSmartDataAttribute *smart_data_attribute)
+guint
+gdu_ata_smart_attribute_get_id (GduAtaSmartAttribute *attribute)
{
- return smart_data_attribute->priv->id;
+ return attribute->priv->id;
}
-int
-gdu_smart_data_attribute_get_flags (GduSmartDataAttribute *smart_data_attribute)
+guint
+gdu_ata_smart_attribute_get_flags (GduAtaSmartAttribute *attribute)
{
- return smart_data_attribute->priv->flags;
+ return attribute->priv->flags;
}
-int
-gdu_smart_data_attribute_get_value (GduSmartDataAttribute *smart_data_attribute)
+gboolean
+gdu_ata_smart_attribute_get_online (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->online;
+}
+
+gboolean
+gdu_ata_smart_attribute_get_prefailure (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->prefailure;
+}
+
+guint
+gdu_ata_smart_attribute_get_current (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->current;
+}
+
+gboolean
+gdu_ata_smart_attribute_get_current_valid (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->current_valid;
+}
+
+guint
+gdu_ata_smart_attribute_get_worst (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->worst;
+}
+
+gboolean
+gdu_ata_smart_attribute_get_worst_valid (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->worst_valid;
+}
+
+guint
+gdu_ata_smart_attribute_get_threshold (GduAtaSmartAttribute *attribute)
{
- return smart_data_attribute->priv->value;
+ return attribute->priv->threshold;
}
-int
-gdu_smart_data_attribute_get_worst (GduSmartDataAttribute *smart_data_attribute)
+gboolean
+gdu_ata_smart_attribute_get_threshold_valid (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->threshold_valid;
+}
+
+gboolean
+gdu_ata_smart_attribute_get_good (GduAtaSmartAttribute *attribute)
{
- return smart_data_attribute->priv->worst;
+ return attribute->priv->good;
}
-int
-gdu_smart_data_attribute_get_threshold (GduSmartDataAttribute *smart_data_attribute)
+gboolean
+gdu_ata_smart_attribute_get_good_valid (GduAtaSmartAttribute *attribute)
{
- return smart_data_attribute->priv->threshold;
+ return attribute->priv->good_valid;
}
-char *
-gdu_smart_data_attribute_get_raw (GduSmartDataAttribute *smart_data_attribute)
+guint64
+gdu_ata_smart_attribute_get_pretty_value (GduAtaSmartAttribute *attribute)
{
- return g_strdup (smart_data_attribute->priv->raw);
+ return attribute->priv->pretty_value;
+}
+
+GduAtaSmartAttributeUnit
+gdu_ata_smart_attribute_get_pretty_unit (GduAtaSmartAttribute *attribute)
+{
+ return attribute->priv->pretty_unit;
}
static void
-attribute_get_details (GduSmartDataAttribute *attr,
- char **out_name,
- char **out_description,
- gboolean *out_should_warn)
+attribute_get_details (GduAtaSmartAttribute *attr,
+ gchar **out_name,
+ gchar **out_description,
+ gboolean *out_warn)
{
const char *n;
const char *d;
gboolean warn;
- int raw_int;
- raw_int = atoi (attr->priv->raw);
-
- /* See http://smartmontools.sourceforge.net/doc.html
+ /* See http://ata_smartmontools.sourceforge.net/doc.html
* http://en.wikipedia.org/wiki/S.M.A.R.T
- * http://www.t13.org/Documents/UploadedDocuments/docs2005/e05148r0-ACS-SMARTAttributesAnnex.pdf
+ * http://www.t13.org/Documents/UploadedDocuments/docs2005/e05148r0-ACS-ATA_SMARTAttributesAnnex.pdf
*/
n = NULL;
@@ -216,7 +265,7 @@ attribute_get_details (GduSmartDataAttribute *attr,
"successfully, this value is decreased and the sector is not remapped. Read "
"errors on the sector will not remap the sector, it will only be remapped on "
"a failed write attempt.");
- if (raw_int > 0)
+ if (attr->priv->pretty_value > 0)
warn = TRUE;
break;
case 198:
@@ -334,62 +383,64 @@ attribute_get_details (GduSmartDataAttribute *attr,
*out_name = g_strdup (n);
if (out_description != NULL)
*out_description = g_strdup (d);
- if (out_should_warn != NULL)
- *out_should_warn = warn;
+ if (out_warn != NULL)
+ *out_warn = warn;
}
-char *
-gdu_smart_data_attribute_get_name (GduSmartDataAttribute *smart_data_attribute)
+const gchar *
+gdu_ata_smart_attribute_get_name (GduAtaSmartAttribute *attribute)
{
- char *s;
- attribute_get_details (smart_data_attribute, &s, NULL, NULL);
- if (s == NULL)
- s = g_strdup (smart_data_attribute->priv->name);
- return s;
+ return attribute->priv->name;
}
-char *
-gdu_smart_data_attribute_get_description (GduSmartDataAttribute *smart_data_attribute)
+gchar *
+gdu_ata_smart_attribute_get_localized_name (GduAtaSmartAttribute *attribute)
{
char *s;
- attribute_get_details (smart_data_attribute, NULL, &s, NULL);
+ attribute_get_details (attribute, &s, NULL, NULL);
+ if (s == NULL)
+ s = g_strdup (attribute->priv->name);
return s;
}
-gboolean
-gdu_smart_data_attribute_is_warning (GduSmartDataAttribute *smart_data_attribute)
+gchar *
+gdu_ata_smart_attribute_get_localized_description (GduAtaSmartAttribute *attribute)
{
- gboolean should_warn;
- attribute_get_details (smart_data_attribute, NULL, NULL, &should_warn);
- return should_warn;
-}
-
-gboolean
-gdu_smart_data_attribute_is_failing (GduSmartDataAttribute *smart_data_attribute)
-{
- return smart_data_attribute->priv->value < smart_data_attribute->priv->threshold;
+ char *s;
+ attribute_get_details (attribute, NULL, &s, NULL);
+ return s;
}
-GduSmartDataAttribute *
-_gdu_smart_data_attribute_new (gpointer data)
+GduAtaSmartAttribute *
+_gdu_ata_smart_attribute_new (gpointer data)
{
GValue elem = {0};
- GduSmartDataAttribute *smart_data_attribute;
+ GduAtaSmartAttribute *attribute;
- smart_data_attribute = GDU_SMART_DATA_ATTRIBUTE (g_object_new (GDU_TYPE_SMART_DATA_ATTRIBUTE, NULL));
+ attribute = GDU_ATA_SMART_ATTRIBUTE (g_object_new (GDU_TYPE_ATA_SMART_ATTRIBUTE, NULL));
- g_value_init (&elem, SMART_DATA_STRUCT_TYPE);
+ g_value_init (&elem, ATA_SMART_ATTRIBUTE_STRUCT_TYPE);
g_value_set_static_boxed (&elem, data);
+
dbus_g_type_struct_get (&elem,
- 0, &(smart_data_attribute->priv->id),
- 1, &(smart_data_attribute->priv->name),
- 2, &(smart_data_attribute->priv->flags),
- 3, &(smart_data_attribute->priv->value),
- 4, &(smart_data_attribute->priv->worst),
- 5, &(smart_data_attribute->priv->threshold),
- 6, &(smart_data_attribute->priv->raw),
+ 0, &attribute->priv->id,
+ 1, &attribute->priv->name,
+ 2, &attribute->priv->flags,
+ 3, &attribute->priv->online,
+ 4, &attribute->priv->prefailure,
+ 5, &attribute->priv->current,
+ 6, &attribute->priv->current_valid,
+ 7, &attribute->priv->worst,
+ 8, &attribute->priv->worst_valid,
+ 9, &attribute->priv->threshold,
+ 10, &attribute->priv->threshold_valid,
+ 11, &attribute->priv->good,
+ 12, &attribute->priv->good_valid,
+ 13, &attribute->priv->pretty_unit,
+ 14, &attribute->priv->pretty_value,
+ //15, &raw_data,
G_MAXUINT);
- return smart_data_attribute;
+ return attribute;
}
diff --git a/src/gdu/gdu-ata-smart-attribute.h b/src/gdu/gdu-ata-smart-attribute.h
new file mode 100644
index 0000000..d0ea3f2
--- /dev/null
+++ b/src/gdu/gdu-ata-smart-attribute.h
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-ata-smart-attribute.h
+ *
+ * Copyright (C) 2009 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#if !defined (__GDU_INSIDE_GDU_H) && !defined (GDU_COMPILATION)
+#error "Only <gdu/gdu.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __GDU_ATA_SMART_ATTRIBUTE_H
+#define __GDU_ATA_SMART_ATTRIBUTE_H
+
+#include <gdu/gdu-types.h>
+
+G_BEGIN_DECLS
+
+#define GDU_TYPE_ATA_SMART_ATTRIBUTE (gdu_ata_smart_attribute_get_type ())
+#define GDU_ATA_SMART_ATTRIBUTE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_ATA_SMART_ATTRIBUTE, GduAtaSmartAttribute))
+#define GDU_ATA_SMART_ATTRIBUTE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GDU_ATA_SMART_ATTRIBUTE, GduAtaSmartAttributeClass))
+#define GDU_IS_ATA_SMART_ATTRIBUTE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_ATA_SMART_ATTRIBUTE))
+#define GDU_IS_ATA_SMART_ATTRIBUTE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDU_TYPE_ATA_SMART_ATTRIBUTE))
+#define GDU_ATA_SMART_ATTRIBUTE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDU_TYPE_ATA_SMART_ATTRIBUTE, GduAtaSmartAttributeClass))
+
+typedef struct _GduAtaSmartAttributeClass GduAtaSmartAttributeClass;
+typedef struct _GduAtaSmartAttributePrivate GduAtaSmartAttributePrivate;
+
+struct _GduAtaSmartAttribute
+{
+ GObject parent;
+
+ /*< private >*/
+ GduAtaSmartAttributePrivate *priv;
+};
+
+struct _GduAtaSmartAttributeClass
+{
+ GObjectClass parent_class;
+
+};
+
+typedef enum {
+ GDU_ATA_SMART_ATTRIBUTE_UNIT_UNKNOWN,
+ GDU_ATA_SMART_ATTRIBUTE_UNIT_NONE,
+ GDU_ATA_SMART_ATTRIBUTE_UNIT_MSECONDS,
+ GDU_ATA_SMART_ATTRIBUTE_UNIT_SECTORS,
+ GDU_ATA_SMART_ATTRIBUTE_UNIT_MKELVIN,
+} GduAtaSmartAttributeUnit;
+
+GType gdu_ata_smart_attribute_get_type (void);
+guint gdu_ata_smart_attribute_get_id (GduAtaSmartAttribute *attribute);
+const gchar *gdu_ata_smart_attribute_get_name (GduAtaSmartAttribute *attribute);
+gchar *gdu_ata_smart_attribute_get_localized_name (GduAtaSmartAttribute *attribute);
+gchar *gdu_ata_smart_attribute_get_localized_description (GduAtaSmartAttribute *attribute);
+guint gdu_ata_smart_attribute_get_flags (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_online (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_prefailure (GduAtaSmartAttribute *attribute);
+guint gdu_ata_smart_attribute_get_current (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_current_valid (GduAtaSmartAttribute *attribute);
+guint gdu_ata_smart_attribute_get_worst (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_worst_valid (GduAtaSmartAttribute *attribute);
+guint gdu_ata_smart_attribute_get_threshold (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_threshold_valid (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_good (GduAtaSmartAttribute *attribute);
+gboolean gdu_ata_smart_attribute_get_good_valid (GduAtaSmartAttribute *attribute);
+guint64 gdu_ata_smart_attribute_get_pretty_value (GduAtaSmartAttribute *attribute);
+GduAtaSmartAttributeUnit gdu_ata_smart_attribute_get_pretty_unit (GduAtaSmartAttribute *attribute);
+
+G_END_DECLS
+
+#endif /* __GDU_ATA_SMART_ATTRIBUTE_H */
diff --git a/src/gdu/gdu-ata-smart-historical-data.c b/src/gdu/gdu-ata-smart-historical-data.c
new file mode 100644
index 0000000..dfc427c
--- /dev/null
+++ b/src/gdu/gdu-ata-smart-historical-data.c
@@ -0,0 +1,181 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-ata-smart-historical-data.c
+ *
+ * Copyright (C) 2009 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib/gi18n.h>
+#include <dbus/dbus-glib.h>
+#include <time.h>
+
+#include "gdu-private.h"
+#include "gdu-ata-smart-historical-data.h"
+#include "gdu-ata-smart-attribute.h"
+
+struct _GduAtaSmartHistoricalDataPrivate {
+ guint64 time_collected;
+ gboolean is_failing;
+ gboolean is_failing_valid;
+ gboolean has_bad_sectors;
+ gboolean has_bad_attributes;
+ gdouble temperature_kelvin;
+ guint64 power_on_seconds;
+ GList *attrs;
+};
+
+static GObjectClass *parent_class = NULL;
+
+G_DEFINE_TYPE (GduAtaSmartHistoricalData, gdu_ata_smart_historical_data, G_TYPE_OBJECT);
+
+static void
+gdu_ata_smart_historical_data_finalize (GduAtaSmartHistoricalData *ata_smart_historical_data)
+{
+ g_list_foreach (ata_smart_historical_data->priv->attrs, (GFunc) g_object_unref, NULL);
+ g_list_free (ata_smart_historical_data->priv->attrs);
+ if (G_OBJECT_CLASS (parent_class)->finalize)
+ (* G_OBJECT_CLASS (parent_class)->finalize) (G_OBJECT (ata_smart_historical_data));
+}
+
+static void
+gdu_ata_smart_historical_data_class_init (GduAtaSmartHistoricalDataClass *klass)
+{
+ GObjectClass *obj_class = (GObjectClass *) klass;
+
+ parent_class = g_type_class_peek_parent (klass);
+
+ obj_class->finalize = (GObjectFinalizeFunc) gdu_ata_smart_historical_data_finalize;
+
+ g_type_class_add_private (klass, sizeof (GduAtaSmartHistoricalDataPrivate));
+}
+
+static void
+gdu_ata_smart_historical_data_init (GduAtaSmartHistoricalData *ata_smart_historical_data)
+{
+ ata_smart_historical_data->priv = G_TYPE_INSTANCE_GET_PRIVATE (ata_smart_historical_data, GDU_TYPE_ATA_SMART_HISTORICAL_DATA, GduAtaSmartHistoricalDataPrivate);
+}
+
+guint64
+gdu_ata_smart_historical_data_get_time_collected (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->time_collected;
+}
+
+gboolean
+gdu_ata_smart_historical_data_get_is_failing (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->is_failing;
+}
+
+gboolean
+gdu_ata_smart_historical_data_get_is_failing_valid (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->is_failing_valid;
+}
+
+gboolean
+gdu_ata_smart_historical_data_get_has_bad_sectors (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->has_bad_sectors;
+}
+
+gboolean
+gdu_ata_smart_historical_data_get_has_bad_attributes (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->has_bad_attributes;
+}
+
+gdouble
+gdu_ata_smart_historical_data_get_temperature_kelvin (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->temperature_kelvin;
+}
+
+guint64
+gdu_ata_smart_historical_data_get_power_on_seconds (GduAtaSmartHistoricalData *data)
+{
+ return data->priv->power_on_seconds;
+}
+
+GList *
+gdu_ata_smart_historical_data_get_attributes (GduAtaSmartHistoricalData *data)
+{
+ GList *ret;
+ ret = g_list_copy (data->priv->attrs);
+ g_list_foreach (ret, (GFunc) g_object_ref, NULL);
+ return ret;
+}
+
+GduAtaSmartAttribute *
+gdu_ata_smart_historical_data_get_attribute (GduAtaSmartHistoricalData *data,
+ const gchar *attr_name)
+{
+ GList *l;
+ GduAtaSmartAttribute *ret;
+
+ /* TODO: if this is slow we can do a hash table */
+
+ ret = NULL;
+
+ for (l = data->priv->attrs; l != NULL; l = l->next) {
+ GduAtaSmartAttribute *a = GDU_ATA_SMART_ATTRIBUTE (l->data);
+ if (g_strcmp0 (attr_name, gdu_ata_smart_attribute_get_name (a)) == 0) {
+ ret = g_object_ref (a);
+ goto out;
+ }
+ }
+out:
+ return ret;
+}
+
+GduAtaSmartHistoricalData *
+_gdu_ata_smart_historical_data_new (gpointer data)
+{
+ GduAtaSmartHistoricalData *ret;
+ GValue elem0 = {0};
+ GPtrArray *attrs;
+ int n;
+
+ ret = GDU_ATA_SMART_HISTORICAL_DATA (g_object_new (GDU_TYPE_ATA_SMART_HISTORICAL_DATA, NULL));
+
+ g_value_init (&elem0, ATA_SMART_HISTORICAL_DATA_STRUCT_TYPE);
+ g_value_set_static_boxed (&elem0, data);
+ dbus_g_type_struct_get (&elem0,
+ 0, &(ret->priv->time_collected),
+ 1, &(ret->priv->is_failing),
+ 2, &(ret->priv->is_failing_valid),
+ 3, &(ret->priv->has_bad_sectors),
+ 4, &(ret->priv->has_bad_attributes),
+ 5, &(ret->priv->temperature_kelvin),
+ 6, &(ret->priv->power_on_seconds),
+ 7, &attrs,
+ G_MAXUINT);
+
+ ret->priv->attrs = NULL;
+ if (attrs != NULL) {
+ for (n = 0; n < (int) attrs->len; n++) {
+ ret->priv->attrs = g_list_prepend (ret->priv->attrs,
+ _gdu_ata_smart_attribute_new (attrs->pdata[n]));
+ }
+ ret->priv->attrs = g_list_reverse (ret->priv->attrs);
+ }
+
+ return ret;
+}
diff --git a/src/gdu/gdu-ata-smart-historical-data.h b/src/gdu/gdu-ata-smart-historical-data.h
new file mode 100644
index 0000000..87031f0
--- /dev/null
+++ b/src/gdu/gdu-ata-smart-historical-data.h
@@ -0,0 +1,72 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+/* gdu-ata-smart-historical-data.h
+ *
+ * Copyright (C) 2007 David Zeuthen
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+
+#if !defined (__GDU_INSIDE_GDU_H) && !defined (GDU_COMPILATION)
+#error "Only <gdu/gdu.h> can be included directly, this file may disappear or change contents."
+#endif
+
+#ifndef __GDU_ATA_SMART_HISTORICAL_DATA_H
+#define __GDU_ATA_SMART_HISTORICAL_DATA_H
+
+#include <gdu/gdu-types.h>
+
+G_BEGIN_DECLS
+
+#define GDU_TYPE_ATA_SMART_HISTORICAL_DATA (gdu_ata_smart_historical_data_get_type ())
+#define GDU_ATA_SMART_HISTORICAL_DATA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_ATA_SMART_HISTORICAL_DATA, GduAtaSmartHistoricalData))
+#define GDU_ATA_SMART_HISTORICAL_DATA_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GDU_ATA_SMART_HISTORICAL_DATA, GduAtaSmartHistoricalDataClass))
+#define GDU_IS_ATA_SMART_HISTORICAL_DATA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_ATA_SMART_HISTORICAL_DATA))
+#define GDU_IS_ATA_SMART_HISTORICAL_DATA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDU_TYPE_ATA_SMART_HISTORICAL_DATA))
+#define GDU_ATA_SMART_HISTORICAL_DATA_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDU_TYPE_ATA_SMART_HISTORICAL_DATA, GduAtaSmartHistoricalDataClass))
+
+typedef struct _GduAtaSmartHistoricalDataClass GduAtaSmartHistoricalDataClass;
+typedef struct _GduAtaSmartHistoricalDataPrivate GduAtaSmartHistoricalDataPrivate;
+
+struct _GduAtaSmartHistoricalData
+{
+ GObject parent;
+
+ /* private */
+ GduAtaSmartHistoricalDataPrivate *priv;
+};
+
+struct _GduAtaSmartHistoricalDataClass
+{
+ GObjectClass parent_class;
+
+};
+
+GType gdu_ata_smart_historical_data_get_type (void);
+guint64 gdu_ata_smart_historical_data_get_time_collected (GduAtaSmartHistoricalData *data);
+gboolean gdu_ata_smart_historical_data_get_is_failing (GduAtaSmartHistoricalData *data);
+gboolean gdu_ata_smart_historical_data_get_is_failing_valid (GduAtaSmartHistoricalData *data);
+gboolean gdu_ata_smart_historical_data_get_has_bad_sectors (GduAtaSmartHistoricalData *data);
+gboolean gdu_ata_smart_historical_data_get_has_bad_attributes (GduAtaSmartHistoricalData *data);
+gdouble gdu_ata_smart_historical_data_get_temperature_kelvin (GduAtaSmartHistoricalData *data);
+guint64 gdu_ata_smart_historical_data_get_power_on_seconds (GduAtaSmartHistoricalData *data);
+GList *gdu_ata_smart_historical_data_get_attributes (GduAtaSmartHistoricalData *data);
+GduAtaSmartAttribute *gdu_ata_smart_historical_data_get_attribute (GduAtaSmartHistoricalData *data,
+ const gchar *attr_name);
+
+G_END_DECLS
+
+#endif /* __GDU_ATA_SMART_HISTORICAL_DATA_H */
diff --git a/src/gdu/gdu-callbacks.h b/src/gdu/gdu-callbacks.h
index 890d9b5..1d68603 100644
--- a/src/gdu/gdu-callbacks.h
+++ b/src/gdu/gdu-callbacks.h
@@ -84,13 +84,13 @@ typedef void (*GduDeviceFilesystemSetLabelCompletedFunc) (GduDevice *device,
GError *error,
gpointer user_data);
-typedef void (*GduDeviceDriveSmartInitiateSelftestCompletedFunc) (GduDevice *device,
- GError *error,
- gpointer user_data);
+typedef void (*GduDeviceDriveAtaSmartInitiateSelftestCompletedFunc) (GduDevice *device,
+ GError *error,
+ gpointer user_data);
-typedef void (*GduDeviceDriveSmartRefreshDataCompletedFunc) (GduDevice *device,
- GError *error,
- gpointer user_data);
+typedef void (*GduDeviceDriveAtaSmartRefreshDataCompletedFunc) (GduDevice *device,
+ GError *error,
+ gpointer user_data);
typedef void (*GduDeviceLinuxMdStopCompletedFunc) (GduDevice *device,
GError *error,
@@ -117,14 +117,10 @@ typedef void (*GduDeviceCancelJobCompletedFunc) (GduDevice *device,
GError *error,
gpointer user_data);
-typedef void (*GduDeviceDriveSmartGetHistoricalDataCompletedFunc) (GduDevice *device,
- GList *smart_data,
- GError *error,
- gpointer user_data);
-
-void gdu_device_drive_smart_get_historical_data (GduDevice *device,
- GduDeviceDriveSmartGetHistoricalDataCompletedFunc callback,
- gpointer user_data);
+typedef void (*GduDeviceDriveAtaSmartGetHistoricalDataCompletedFunc) (GduDevice *device,
+ GList *smart_data,
+ GError *error,
+ gpointer user_data);
typedef void (*GduDeviceFilesystemListOpenFilesCompletedFunc) (GduDevice *device,
GList *processes,
diff --git a/src/gdu/gdu-device.c b/src/gdu/gdu-device.c
index 60ec7e7..8205151 100644
--- a/src/gdu/gdu-device.c
+++ b/src/gdu/gdu-device.c
@@ -31,6 +31,7 @@
#include "gdu-private.h"
#include "gdu-pool.h"
#include "gdu-device.h"
+#include "gdu-ata-smart-attribute.h"
#include "devkit-disks-device-glue.h"
/* --- SUCKY CODE BEGIN --- */
@@ -127,14 +128,26 @@ typedef struct
guint optical_disc_num_audio_tracks;
guint optical_disc_num_sessions;
- gboolean drive_smart_is_capable;
- gboolean drive_smart_is_enabled;
- guint64 drive_smart_time_collected;
- gboolean drive_smart_is_failing;
- double drive_smart_temperature;
- guint64 drive_smart_time_powered_on;
- char *drive_smart_last_self_test_result;
- GValue drive_smart_attributes;
+ gboolean drive_ata_smart_is_available;
+ gboolean drive_ata_smart_is_failing;
+ gboolean drive_ata_smart_is_failing_valid;
+ gboolean drive_ata_smart_has_bad_sectors;
+ gboolean drive_ata_smart_has_bad_attributes;
+ gdouble drive_ata_smart_temperature_kelvin;
+ guint64 drive_ata_smart_power_on_seconds;
+ guint64 drive_ata_smart_time_collected;
+ guint drive_ata_smart_offline_data_collection_status;
+ guint drive_ata_smart_offline_data_collection_seconds;
+ guint drive_ata_smart_self_test_execution_status;
+ guint drive_ata_smart_self_test_execution_percent_remaining;
+ gboolean drive_ata_smart_short_and_extended_self_test_available;
+ gboolean drive_ata_smart_conveyance_self_test_available;
+ gboolean drive_ata_smart_start_self_test_available;
+ gboolean drive_ata_smart_abort_self_test_available;
+ guint drive_ata_smart_short_self_test_polling_minutes;
+ guint drive_ata_smart_extended_self_test_polling_minutes;
+ guint drive_ata_smart_conveyance_self_test_polling_minutes;
+ GValue drive_ata_smart_attributes;
char *linux_md_component_level;
int linux_md_component_num_raid_devices;
@@ -329,22 +342,46 @@ collect_props (const char *key, const GValue *value, DeviceProperties *props)
else if (strcmp (key, "optical-disc-num-sessions") == 0)
props->optical_disc_num_sessions = g_value_get_uint (value);
- else if (strcmp (key, "drive-smart-is-capable") == 0)
- props->drive_smart_is_capable = g_value_get_boolean (value);
- else if (strcmp (key, "drive-smart-is-enabled") == 0)
- props->drive_smart_is_enabled = g_value_get_boolean (value);
- else if (strcmp (key, "drive-smart-time-collected") == 0)
- props->drive_smart_time_collected = g_value_get_uint64 (value);
- else if (strcmp (key, "drive-smart-is-failing") == 0)
- props->drive_smart_is_failing = g_value_get_boolean (value);
- else if (strcmp (key, "drive-smart-temperature") == 0)
- props->drive_smart_temperature = g_value_get_double (value);
- else if (strcmp (key, "drive-smart-time-powered-on") == 0)
- props->drive_smart_time_powered_on = g_value_get_uint64 (value);
- else if (strcmp (key, "drive-smart-last-self-test-result") == 0)
- props->drive_smart_last_self_test_result = g_strdup (g_value_get_string (value));
- else if (strcmp (key, "drive-smart-attributes") == 0) {
- g_value_copy (value, &(props->drive_smart_attributes));
+ else if (strcmp (key, "drive-ata-smart-is-available") == 0)
+ props->drive_ata_smart_is_available = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-is-failing") == 0)
+ props->drive_ata_smart_is_failing = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-is-failing-valid") == 0)
+ props->drive_ata_smart_is_failing_valid = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-has-bad-sectors") == 0)
+ props->drive_ata_smart_has_bad_sectors = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-has-bad-attributes") == 0)
+ props->drive_ata_smart_has_bad_attributes = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-temperature-kelvin") == 0)
+ props->drive_ata_smart_temperature_kelvin = g_value_get_double (value);
+ else if (strcmp (key, "drive-ata-smart-power-on-seconds") == 0)
+ props->drive_ata_smart_power_on_seconds = g_value_get_uint64 (value);
+ else if (strcmp (key, "drive-ata-smart-time-collected") == 0)
+ props->drive_ata_smart_time_collected = g_value_get_uint64 (value);
+ else if (strcmp (key, "drive-ata-smart-offline-data-collection-status") == 0)
+ props->drive_ata_smart_offline_data_collection_status = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-offline-data-collection-seconds") == 0)
+ props->drive_ata_smart_offline_data_collection_seconds = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-self-test-execution-status") == 0)
+ props->drive_ata_smart_self_test_execution_status = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-self-test-execution-percent-remaining") == 0)
+ props->drive_ata_smart_self_test_execution_percent_remaining = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-short-and-extended-self-test-available") == 0)
+ props->drive_ata_smart_short_and_extended_self_test_available = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-conveyance-self-test-available") == 0)
+ props->drive_ata_smart_conveyance_self_test_available = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-start-self-test-available") == 0)
+ props->drive_ata_smart_start_self_test_available = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-abort-self-test-available") == 0)
+ props->drive_ata_smart_abort_self_test_available = g_value_get_boolean (value);
+ else if (strcmp (key, "drive-ata-smart-short-self-test-polling-minutes") == 0)
+ props->drive_ata_smart_short_self_test_polling_minutes = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-extended-self-test-polling-minutes") == 0)
+ props->drive_ata_smart_extended_self_test_polling_minutes = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-conveyance-self-test-polling-minutes") == 0)
+ props->drive_ata_smart_conveyance_self_test_polling_minutes = g_value_get_uint (value);
+ else if (strcmp (key, "drive-ata-smart-attributes") == 0) {
+ g_value_copy (value, &(props->drive_ata_smart_attributes));
}
else if (strcmp (key, "linux-md-component-level") == 0)
@@ -441,8 +478,9 @@ device_properties_free (DeviceProperties *props)
g_free (props->drive_connection_interface);
g_strfreev (props->drive_media_compatibility);
g_free (props->drive_media);
- g_free (props->drive_smart_last_self_test_result);
- g_value_unset (&(props->drive_smart_attributes));
+
+ g_value_unset (&(props->drive_ata_smart_attributes));
+
g_free (props->linux_md_component_level);
g_free (props->linux_md_component_uuid);
g_free (props->linux_md_component_home_host);
@@ -473,8 +511,8 @@ device_properties_get (DBusGConnection *bus,
const char *ifname = "org.freedesktop.DeviceKit.Disks.Device";
props = g_new0 (DeviceProperties, 1);
- g_value_init (&(props->drive_smart_attributes),
- dbus_g_type_get_collection ("GPtrArray", SMART_DATA_STRUCT_TYPE));
+ g_value_init (&(props->drive_ata_smart_attributes),
+ dbus_g_type_get_collection ("GPtrArray", ATA_SMART_ATTRIBUTE_STRUCT_TYPE));
prop_proxy = dbus_g_proxy_new_for_name (bus,
"org.freedesktop.DeviceKit.Disks",
@@ -1113,30 +1151,6 @@ gdu_device_optical_disc_get_num_sessions (GduDevice *device)
return device->priv->props->optical_disc_num_sessions;
}
-
-gboolean
-gdu_device_drive_smart_get_is_capable (GduDevice *device)
-{
- return device->priv->props->drive_smart_is_capable;
-}
-
-gboolean
-gdu_device_drive_smart_get_is_enabled (GduDevice *device)
-{
- return device->priv->props->drive_smart_is_enabled;
-}
-
-GduSmartData *
-gdu_device_get_smart_data (GduDevice *device)
-{
- return _gdu_smart_data_new_from_values (device->priv->props->drive_smart_time_collected,
- device->priv->props->drive_smart_temperature,
- device->priv->props->drive_smart_time_powered_on,
- device->priv->props->drive_smart_last_self_test_result,
- device->priv->props->drive_smart_is_failing,
- g_value_get_boxed (&(device->priv->props->drive_smart_attributes)));
-}
-
const char *
gdu_device_linux_md_component_get_level (GduDevice *device)
{
@@ -1260,6 +1274,161 @@ gdu_device_linux_md_get_sync_speed (GduDevice *device)
/* ---------------------------------------------------------------------------------------------------- */
gboolean
+gdu_device_drive_ata_smart_get_is_available (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_is_available;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_is_failing (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_is_failing;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_is_failing_valid (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_is_failing_valid;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_has_bad_sectors (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_has_bad_sectors;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_has_bad_attributes (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_has_bad_attributes;
+}
+
+gdouble
+gdu_device_drive_ata_smart_get_temperature_kelvin (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_temperature_kelvin;
+}
+
+guint64 gdu_device_drive_ata_smart_get_power_on_seconds (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_power_on_seconds;
+}
+
+guint64
+gdu_device_drive_ata_smart_get_time_collected (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_time_collected;
+}
+
+GduAtaSmartOfflineDataCollectionStatus
+gdu_device_drive_ata_smart_get_offline_data_collection_status (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_offline_data_collection_status;
+}
+
+guint
+gdu_device_drive_ata_smart_get_offline_data_collection_seconds (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_offline_data_collection_seconds;
+}
+
+GduAtaSmartSelfTestExecutionStatus
+gdu_device_drive_ata_smart_get_self_test_execution_status (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_self_test_execution_status;
+}
+
+guint
+gdu_device_drive_ata_smart_get_self_test_execution_percent_remaining (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_self_test_execution_percent_remaining;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_short_and_extended_self_test_available (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_short_and_extended_self_test_available;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_conveyance_self_test_available (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_conveyance_self_test_available;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_start_self_test_available (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_start_self_test_available;
+}
+
+gboolean
+gdu_device_drive_ata_smart_get_abort_self_test_available (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_abort_self_test_available;
+}
+
+guint
+gdu_device_drive_ata_smart_get_short_self_test_polling_minutes (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_short_self_test_polling_minutes;
+}
+
+guint
+gdu_device_drive_ata_smart_get_extended_self_test_polling_minutes (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_extended_self_test_polling_minutes;
+}
+
+guint
+gdu_device_drive_ata_smart_get_conveyance_self_test_polling_minutes (GduDevice *device)
+{
+ return device->priv->props->drive_ata_smart_conveyance_self_test_polling_minutes;
+}
+
+GList *
+gdu_device_drive_ata_smart_get_attributes (GduDevice *device)
+{
+ GList *ret;
+ GPtrArray *p;
+ guint n;
+
+ ret = NULL;
+
+ p = g_value_get_boxed (&(device->priv->props->drive_ata_smart_attributes));
+ for (n = 0; n < p->len; n++) {
+ ret = g_list_prepend (ret, _gdu_ata_smart_attribute_new (p->pdata[n]));
+ }
+
+ return ret;
+}
+
+GduAtaSmartAttribute *
+gdu_device_drive_ata_smart_get_attribute (GduDevice *device, const gchar *attr_name)
+{
+ GList *attrs;
+ GList *l;
+ GduAtaSmartAttribute *ret;
+
+ ret = NULL;
+
+ attrs = gdu_device_drive_ata_smart_get_attributes (device);
+ for (l = attrs; l != NULL; l = l->next) {
+ GduAtaSmartAttribute *a = GDU_ATA_SMART_ATTRIBUTE (l->data);
+ if (g_strcmp0 (attr_name, gdu_ata_smart_attribute_get_name (a)) == 0) {
+ ret = g_object_ref (a);
+ break;
+ }
+ }
+ g_list_foreach (attrs, (GFunc) g_object_unref, NULL);
+ g_list_free (attrs);
+
+ return ret;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+gboolean
gdu_device_job_in_progress (GduDevice *device)
{
return device->priv->props->job_in_progress;
@@ -1949,14 +2118,14 @@ out:
typedef struct {
GduDevice *device;
- GduDeviceDriveSmartRefreshDataCompletedFunc callback;
+ GduDeviceDriveAtaSmartRefreshDataCompletedFunc callback;
gpointer user_data;
-} RetrieveSmartDataData;
+} RetrieveAtaSmartDataData;
static void
-op_retrieve_smart_data_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
+op_retrieve_ata_smart_data_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{
- RetrieveSmartDataData *data = user_data;
+ RetrieveAtaSmartDataData *data = user_data;
_gdu_error_fixup (error);
if (data->callback != NULL)
data->callback (data->device, error, data->user_data);
@@ -1965,23 +2134,23 @@ op_retrieve_smart_data_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
}
void
-gdu_device_drive_smart_refresh_data (GduDevice *device,
- GduDeviceDriveSmartRefreshDataCompletedFunc callback,
+gdu_device_drive_ata_smart_refresh_data (GduDevice *device,
+ GduDeviceDriveAtaSmartRefreshDataCompletedFunc callback,
gpointer user_data)
{
- RetrieveSmartDataData *data;
+ RetrieveAtaSmartDataData *data;
char *options[16];
options[0] = NULL;
- data = g_new0 (RetrieveSmartDataData, 1);
+ data = g_new0 (RetrieveAtaSmartDataData, 1);
data->device = g_object_ref (device);
data->callback = callback;
data->user_data = user_data;
- org_freedesktop_DeviceKit_Disks_Device_drive_smart_refresh_data_async (device->priv->proxy,
+ org_freedesktop_DeviceKit_Disks_Device_drive_ata_smart_refresh_data_async (device->priv->proxy,
(const char **) options,
- op_retrieve_smart_data_cb,
+ op_retrieve_ata_smart_data_cb,
data);
}
@@ -1989,14 +2158,14 @@ gdu_device_drive_smart_refresh_data (GduDevice
typedef struct {
GduDevice *device;
- GduDeviceDriveSmartInitiateSelftestCompletedFunc callback;
+ GduDeviceDriveAtaSmartInitiateSelftestCompletedFunc callback;
gpointer user_data;
-} DriveSmartInitiateSelftestData;
+} DriveAtaSmartInitiateSelftestData;
static void
-op_run_smart_selftest_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
+op_run_ata_smart_selftest_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
{
- DriveSmartInitiateSelftestData *data = user_data;
+ DriveAtaSmartInitiateSelftestData *data = user_data;
_gdu_error_fixup (error);
if (data->callback != NULL)
data->callback (data->device, error, data->user_data);
@@ -2005,24 +2174,24 @@ op_run_smart_selftest_cb (DBusGProxy *proxy, GError *error, gpointer user_data)
}
void
-gdu_device_op_drive_smart_initiate_selftest (GduDevice *device,
- const char *test,
- gboolean captive,
- GduDeviceDriveSmartInitiateSelftestCompletedFunc callback,
- gpointer user_data)
+gdu_device_op_drive_ata_smart_initiate_selftest (GduDevice *device,
+ const char *test,
+ GduDeviceDriveAtaSmartInitiateSelftestCompletedFunc callback,
+ gpointer user_data)
{
- DriveSmartInitiateSelftestData *data;
+ DriveAtaSmartInitiateSelftestData *data;
+ gchar *options = {NULL};
- data = g_new0 (DriveSmartInitiateSelftestData, 1);
+ data = g_new0 (DriveAtaSmartInitiateSelftestData, 1);
data->device = g_object_ref (device);
data->callback = callback;
data->user_data = user_data;
- org_freedesktop_DeviceKit_Disks_Device_drive_smart_initiate_selftest_async (device->priv->proxy,
- test,
- captive,
- op_run_smart_selftest_cb,
- data);
+ org_freedesktop_DeviceKit_Disks_Device_drive_ata_smart_initiate_selftest_async (device->priv->proxy,
+ test,
+ (const gchar **) options,
+ op_run_ata_smart_selftest_cb,
+ data);
}
/* -------------------------------------------------------------------------------- */
@@ -2198,35 +2367,35 @@ gdu_device_op_cancel_job (GduDevice *device, GduDeviceCancelJobCompletedFunc cal
typedef struct {
GduDevice *device;
- GduDeviceDriveSmartGetHistoricalDataCompletedFunc callback;
+ GduDeviceDriveAtaSmartGetHistoricalDataCompletedFunc callback;
gpointer user_data;
-} DriveSmartGetHistoricalDataData;
+} DriveAtaSmartGetHistoricalDataData;
static GList *
-op_smart_historical_data_compute_ret (GPtrArray *historical_data)
+op_ata_smart_historical_data_compute_ret (GPtrArray *historical_data)
{
GList *ret;
int n;
ret = NULL;
for (n = 0; n < (int) historical_data->len; n++) {
- ret = g_list_prepend (ret, _gdu_smart_data_new (historical_data->pdata[n]));
+ ret = g_list_prepend (ret, _gdu_ata_smart_historical_data_new (historical_data->pdata[n]));
}
ret = g_list_reverse (ret);
return ret;
}
static void
-op_smart_historical_data_cb (DBusGProxy *proxy, GPtrArray *historical_data, GError *error, gpointer user_data)
+op_ata_smart_historical_data_cb (DBusGProxy *proxy, GPtrArray *historical_data, GError *error, gpointer user_data)
{
- DriveSmartGetHistoricalDataData *data = user_data;
+ DriveAtaSmartGetHistoricalDataData *data = user_data;
GList *ret;
_gdu_error_fixup (error);
ret = NULL;
if (historical_data != NULL && error == NULL)
- ret = op_smart_historical_data_compute_ret (historical_data);
+ ret = op_ata_smart_historical_data_compute_ret (historical_data);
if (data->callback == NULL)
data->callback (data->device, ret, error, data->user_data);
@@ -2236,42 +2405,42 @@ op_smart_historical_data_cb (DBusGProxy *proxy, GPtrArray *historical_data, GErr
}
void
-gdu_device_drive_smart_get_historical_data (GduDevice *device,
- GduDeviceDriveSmartGetHistoricalDataCompletedFunc callback,
- gpointer user_data)
+gdu_device_drive_ata_smart_get_historical_data (GduDevice *device,
+ GduDeviceDriveAtaSmartGetHistoricalDataCompletedFunc callback,
+ gpointer user_data)
{
- DriveSmartGetHistoricalDataData *data;
+ DriveAtaSmartGetHistoricalDataData *data;
- data = g_new0 (DriveSmartGetHistoricalDataData, 1);
+ data = g_new0 (DriveAtaSmartGetHistoricalDataData, 1);
data->device = g_object_ref (device);
data->callback = callback;
data->user_data = user_data;
/* TODO: since, until */
- org_freedesktop_DeviceKit_Disks_Device_drive_smart_get_historical_data_async (device->priv->proxy,
+ org_freedesktop_DeviceKit_Disks_Device_drive_ata_smart_get_historical_data_async (device->priv->proxy,
0,
0,
- op_smart_historical_data_cb,
+ op_ata_smart_historical_data_cb,
data);
}
GList *
-gdu_device_drive_smart_get_historical_data_sync (GduDevice *device,
- GError **error)
+gdu_device_drive_ata_smart_get_historical_data_sync (GduDevice *device,
+ GError **error)
{
GList *ret;
GPtrArray *historical_data;
ret = NULL;
/* TODO: since, until */
- if (!org_freedesktop_DeviceKit_Disks_Device_drive_smart_get_historical_data (device->priv->proxy,
+ if (!org_freedesktop_DeviceKit_Disks_Device_drive_ata_smart_get_historical_data (device->priv->proxy,
0,
0,
&historical_data,
error))
goto out;
- ret = op_smart_historical_data_compute_ret (historical_data);
+ ret = op_ata_smart_historical_data_compute_ret (historical_data);
out:
return ret;
}
diff --git a/src/gdu/gdu-device.h b/src/gdu/gdu-device.h
index c631aa8..c3e03ce 100644
--- a/src/gdu/gdu-device.h
+++ b/src/gdu/gdu-device.h
@@ -147,10 +147,6 @@ guint gdu_device_optical_disc_get_num_tracks (GduDevice *device);
guint gdu_device_optical_disc_get_num_audio_tracks (GduDevice *device);
guint gdu_device_optical_disc_get_num_sessions (GduDevice *device);
-gboolean gdu_device_drive_smart_get_is_capable (GduDevice *device);
-gboolean gdu_device_drive_smart_get_is_enabled (GduDevice *device);
-GduSmartData *gdu_device_get_smart_data (GduDevice *device);
-
const char *gdu_device_linux_md_component_get_level (GduDevice *device);
int gdu_device_linux_md_component_get_num_raid_devices (GduDevice *device);
const char *gdu_device_linux_md_component_get_uuid (GduDevice *device);
@@ -173,6 +169,51 @@ const char *gdu_device_linux_md_get_sync_action (GduDevice *device);
double gdu_device_linux_md_get_sync_percentage (GduDevice *device);
guint64 gdu_device_linux_md_get_sync_speed (GduDevice *device);
+typedef enum {
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_NEVER,
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_SUCCESS,
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_INPROGRESS,
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_SUSPENDED,
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_ABORTED,
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_FATAL,
+ GDU_ATA_SMART_OFFLINE_DATA_COLLECTION_STATUS_UNKNOWN,
+} GduAtaSmartOfflineDataCollectionStatus;
+
+typedef enum {
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_SUCCESS_OR_NEVER = 0,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_ABORTED = 1,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_INTERRUPTED = 2,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_FATAL = 3,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_ERROR_UNKNOWN = 4,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_ERROR_ELECTRICAL = 5,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_ERROR_SERVO = 6,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_ERROR_READ = 7,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_ERROR_HANDLING = 8,
+ GDU_ATA_SMART_SELF_TEST_EXECUTION_STATUS_INPROGRESS = 15,
+} GduAtaSmartSelfTestExecutionStatus;
+
+gboolean gdu_device_drive_ata_smart_get_is_available (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_is_failing (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_is_failing_valid (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_has_bad_sectors (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_has_bad_attributes (GduDevice *device);
+gdouble gdu_device_drive_ata_smart_get_temperature_kelvin (GduDevice *device);
+guint64 gdu_device_drive_ata_smart_get_power_on_seconds (GduDevice *device);
+guint64 gdu_device_drive_ata_smart_get_time_collected (GduDevice *device);
+GduAtaSmartOfflineDataCollectionStatus gdu_device_drive_ata_smart_get_offline_data_collection_status (GduDevice *device);
+guint gdu_device_drive_ata_smart_get_offline_data_collection_seconds (GduDevice *device);
+GduAtaSmartSelfTestExecutionStatus gdu_device_drive_ata_smart_get_self_test_execution_status (GduDevice *device);
+guint gdu_device_drive_ata_smart_get_self_test_execution_percent_remaining (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_short_and_extended_self_test_available (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_conveyance_self_test_available (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_start_self_test_available (GduDevice *device);
+gboolean gdu_device_drive_ata_smart_get_abort_self_test_available (GduDevice *device);
+guint gdu_device_drive_ata_smart_get_short_self_test_polling_minutes (GduDevice *device);
+guint gdu_device_drive_ata_smart_get_extended_self_test_polling_minutes (GduDevice *device);
+guint gdu_device_drive_ata_smart_get_conveyance_self_test_polling_minutes (GduDevice *device);
+GList *gdu_device_drive_ata_smart_get_attributes (GduDevice *device);
+GduAtaSmartAttribute *gdu_device_drive_ata_smart_get_attribute (GduDevice *device, const gchar *attr_name);
+
/* ---------------------------------------------------------------------------------------------------- */
void gdu_device_op_filesystem_mount (GduDevice *device,
@@ -245,17 +286,16 @@ void gdu_device_op_filesystem_set_label (GduDevice
/* ---------------------------------------------------------------------------------------------------- */
-void gdu_device_op_drive_smart_initiate_selftest (GduDevice *device,
- const char *test,
- gboolean captive,
- GduDeviceDriveSmartInitiateSelftestCompletedFunc callback,
- gpointer user_data);
+void gdu_device_op_drive_ata_smart_initiate_selftest (GduDevice *device,
+ const char *test,
+ GduDeviceDriveAtaSmartInitiateSelftestCompletedFunc callback,
+ gpointer user_data);
/* ---------------------------------------------------------------------------------------------------- */
-void gdu_device_drive_smart_refresh_data (GduDevice *device,
- GduDeviceDriveSmartRefreshDataCompletedFunc callback,
- gpointer user_data);
+void gdu_device_drive_ata_smart_refresh_data (GduDevice *device,
+ GduDeviceDriveAtaSmartRefreshDataCompletedFunc callback,
+ gpointer user_data);
/* ---------------------------------------------------------------------------------------------------- */
@@ -313,7 +353,11 @@ void gdu_device_op_cancel_job (GduDevice *device,
/* ---------------------------------------------------------------------------------------------------- */
-GList *gdu_device_drive_smart_get_historical_data_sync (GduDevice *device,
+void gdu_device_drive_ata_smart_get_historical_data (GduDevice *device,
+ GduDeviceDriveAtaSmartGetHistoricalDataCompletedFunc callback,
+ gpointer user_data);
+
+GList *gdu_device_drive_ata_smart_get_historical_data_sync (GduDevice *device,
GError **error);
/* ---------------------------------------------------------------------------------------------------- */
diff --git a/src/gdu/gdu-private.h b/src/gdu/gdu-private.h
index 2beaa9f..6c5e45b 100644
--- a/src/gdu/gdu-private.h
+++ b/src/gdu/gdu-private.h
@@ -28,24 +28,29 @@
#include "gdu-types.h"
-#define SMART_DATA_STRUCT_TYPE (dbus_g_type_get_struct ("GValueArray", \
- G_TYPE_INT, \
- G_TYPE_STRING, \
- G_TYPE_INT, \
- G_TYPE_INT, \
- G_TYPE_INT, \
- G_TYPE_INT, \
- G_TYPE_STRING, \
- G_TYPE_INVALID))
-
-#define HISTORICAL_SMART_DATA_STRUCT_TYPE (dbus_g_type_get_struct ("GValueArray", \
- G_TYPE_UINT64, \
- G_TYPE_DOUBLE, \
- G_TYPE_UINT64, \
- G_TYPE_STRING, \
- G_TYPE_BOOLEAN, \
- dbus_g_type_get_collection ("GPtrArray", SMART_DATA_STRUCT_TYPE), \
- G_TYPE_INVALID))
+#define ATA_SMART_ATTRIBUTE_STRUCT_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT, \
+ G_TYPE_STRING, \
+ G_TYPE_UINT, \
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, \
+ G_TYPE_UCHAR, G_TYPE_BOOLEAN, \
+ G_TYPE_UCHAR, G_TYPE_BOOLEAN, \
+ G_TYPE_UCHAR, G_TYPE_BOOLEAN, \
+ G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, \
+ G_TYPE_UINT, G_TYPE_UINT64, \
+ dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR), \
+ G_TYPE_INVALID))
+
+#define ATA_SMART_HISTORICAL_DATA_STRUCT_TYPE (dbus_g_type_get_struct ("GValueArray", \
+ G_TYPE_UINT64, \
+ G_TYPE_BOOLEAN, \
+ G_TYPE_BOOLEAN, \
+ G_TYPE_BOOLEAN, \
+ G_TYPE_BOOLEAN, \
+ G_TYPE_DOUBLE, \
+ G_TYPE_UINT64, \
+ dbus_g_type_get_collection ("GPtrArray", ATA_SMART_ATTRIBUTE_STRUCT_TYPE), \
+ G_TYPE_INVALID))
#define KNOWN_FILESYSTEMS_STRUCT_TYPE (dbus_g_type_get_struct ("GValueArray", \
G_TYPE_STRING, \
@@ -70,15 +75,9 @@
G_TYPE_STRING, \
G_TYPE_INVALID))
-GduSmartDataAttribute *_gdu_smart_data_attribute_new (gpointer data);
-GduSmartData *_gdu_smart_data_new_from_values (guint64 time_collected,
- double temperature,
- guint64 time_powered_on,
- const char *last_self_test_result,
- gboolean is_failing,
- GPtrArray *attrs);
+GduAtaSmartAttribute *_gdu_ata_smart_attribute_new (gpointer data);
-GduSmartData * _gdu_smart_data_new (gpointer data);
+GduAtaSmartHistoricalData * _gdu_ata_smart_historical_data_new (gpointer data);
GduKnownFilesystem *_gdu_known_filesystem_new (gpointer data);
diff --git a/src/gdu/gdu-smart-data-attribute.h b/src/gdu/gdu-smart-data-attribute.h
deleted file mode 100644
index 7d05134..0000000
--- a/src/gdu/gdu-smart-data-attribute.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* gdu-smart-data-attribute.h
- *
- * Copyright (C) 2007 David Zeuthen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#if !defined (__GDU_INSIDE_GDU_H) && !defined (GDU_COMPILATION)
-#error "Only <gdu/gdu.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __GDU_SMART_DATA_ATTRIBUTE_H
-#define __GDU_SMART_DATA_ATTRIBUTE_H
-
-#include <gdu/gdu-types.h>
-
-G_BEGIN_DECLS
-
-#define GDU_TYPE_SMART_DATA_ATTRIBUTE (gdu_smart_data_attribute_get_type ())
-#define GDU_SMART_DATA_ATTRIBUTE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_SMART_DATA_ATTRIBUTE, GduSmartDataAttribute))
-#define GDU_SMART_DATA_ATTRIBUTE_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GDU_SMART_DATA_ATTRIBUTE, GduSmartDataAttributeClass))
-#define GDU_IS_SMART_DATA_ATTRIBUTE(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_SMART_DATA_ATTRIBUTE))
-#define GDU_IS_SMART_DATA_ATTRIBUTE_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDU_TYPE_SMART_DATA_ATTRIBUTE))
-#define GDU_SMART_DATA_ATTRIBUTE_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((k), GDU_TYPE_SMART_DATA_ATTRIBUTE, GduSmartDataAttributeClass))
-
-typedef struct _GduSmartDataAttributeClass GduSmartDataAttributeClass;
-typedef struct _GduSmartDataAttributePrivate GduSmartDataAttributePrivate;
-
-struct _GduSmartDataAttribute
-{
- GObject parent;
-
- /* private */
- GduSmartDataAttributePrivate *priv;
-};
-
-struct _GduSmartDataAttributeClass
-{
- GObjectClass parent_class;
-
-};
-
-GType gdu_smart_data_attribute_get_type (void);
-int gdu_smart_data_attribute_get_id (GduSmartDataAttribute *smart_data_attribute);
-int gdu_smart_data_attribute_get_flags (GduSmartDataAttribute *smart_data_attribute);
-int gdu_smart_data_attribute_get_value (GduSmartDataAttribute *smart_data_attribute);
-int gdu_smart_data_attribute_get_worst (GduSmartDataAttribute *smart_data_attribute);
-int gdu_smart_data_attribute_get_threshold (GduSmartDataAttribute *smart_data_attribute);
-char *gdu_smart_data_attribute_get_raw (GduSmartDataAttribute *smart_data_attribute);
-char *gdu_smart_data_attribute_get_name (GduSmartDataAttribute *smart_data_attribute);
-char *gdu_smart_data_attribute_get_description (GduSmartDataAttribute *smart_data_attribute);
-gboolean gdu_smart_data_attribute_is_warning (GduSmartDataAttribute *smart_data_attribute);
-gboolean gdu_smart_data_attribute_is_failing (GduSmartDataAttribute *smart_data_attribute);
-
-G_END_DECLS
-
-#endif /* __GDU_SMART_DATA_ATTRIBUTE_H */
diff --git a/src/gdu/gdu-smart-data.c b/src/gdu/gdu-smart-data.c
deleted file mode 100644
index cc83764..0000000
--- a/src/gdu/gdu-smart-data.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* gdu-smart-data.c
- *
- * Copyright (C) 2007 David Zeuthen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#include <config.h>
-#include <stdlib.h>
-#include <string.h>
-#include <glib/gi18n.h>
-#include <dbus/dbus-glib.h>
-#include <time.h>
-
-#include "gdu-private.h"
-#include "gdu-smart-data.h"
-#include "gdu-smart-data-attribute.h"
-
-struct _GduSmartDataPrivate {
- guint64 time_collected;
- double temperature;
- guint64 time_powered_on;
- char *last_self_test_result;
- gboolean is_failing;
- GList *attrs;
-};
-
-static GObjectClass *parent_class = NULL;
-
-G_DEFINE_TYPE (GduSmartData, gdu_smart_data, G_TYPE_OBJECT);
-
-static void
-gdu_smart_data_finalize (GduSmartData *smart_data)
-{
- g_free (smart_data->priv->last_self_test_result);
- g_list_foreach (smart_data->priv->attrs, (GFunc) g_object_unref, NULL);
- g_list_free (smart_data->priv->attrs);
- if (G_OBJECT_CLASS (parent_class)->finalize)
- (* G_OBJECT_CLASS (parent_class)->finalize) (G_OBJECT (smart_data));
-}
-
-static void
-gdu_smart_data_class_init (GduSmartDataClass *klass)
-{
- GObjectClass *obj_class = (GObjectClass *) klass;
-
- parent_class = g_type_class_peek_parent (klass);
-
- obj_class->finalize = (GObjectFinalizeFunc) gdu_smart_data_finalize;
-
- g_type_class_add_private (klass, sizeof (GduSmartDataPrivate));
-}
-
-static void
-gdu_smart_data_init (GduSmartData *smart_data)
-{
- smart_data->priv = G_TYPE_INSTANCE_GET_PRIVATE (smart_data, GDU_TYPE_SMART_DATA, GduSmartDataPrivate);
-}
-
-guint64
-gdu_smart_data_get_time_collected (GduSmartData *smart_data)
-{
- return smart_data->priv->time_collected;
-}
-
-double
-gdu_smart_data_get_temperature (GduSmartData *smart_data)
-{
- return smart_data->priv->temperature;
-}
-
-guint64
-gdu_smart_data_get_time_powered_on (GduSmartData *smart_data)
-{
- return smart_data->priv->time_powered_on;
-}
-
-char *
-gdu_smart_data_get_last_self_test_result (GduSmartData *smart_data)
-{
- return g_strdup (smart_data->priv->last_self_test_result);
-}
-
-gboolean
-gdu_smart_data_get_attribute_warning (GduSmartData *smart_data)
-{
- GList *l;
- gboolean ret;
-
- ret = FALSE;
- for (l = smart_data->priv->attrs; l != NULL; l = l->next) {
- GduSmartDataAttribute *attr = GDU_SMART_DATA_ATTRIBUTE (l->data);
- if (gdu_smart_data_attribute_is_warning (attr)) {
- ret = TRUE;
- goto out;
- }
- }
-out:
- return ret;
-}
-
-gboolean
-gdu_smart_data_get_attribute_failing (GduSmartData *smart_data)
-{
- GList *l;
- gboolean ret;
-
- ret = FALSE;
- for (l = smart_data->priv->attrs; l != NULL; l = l->next) {
- GduSmartDataAttribute *attr = GDU_SMART_DATA_ATTRIBUTE (l->data);
- if (gdu_smart_data_attribute_is_failing (attr)) {
- ret = TRUE;
- goto out;
- }
- }
-out:
- return ret;
-}
-
-gboolean
-gdu_smart_data_get_is_failing (GduSmartData *smart_data)
-{
- return smart_data->priv->is_failing;
-}
-
-GList *
-gdu_smart_data_get_attributes (GduSmartData *smart_data)
-{
- GList *ret;
- ret = g_list_copy (smart_data->priv->attrs);
- g_list_foreach (ret, (GFunc) g_object_ref, NULL);
- return ret;
-}
-
-GduSmartDataAttribute *
-gdu_smart_data_get_attribute (GduSmartData *smart_data,
- int id)
-{
- GList *l;
- GduSmartDataAttribute *ret;
-
- /* TODO: if this is slow we can do a hash table */
-
- ret = NULL;
-
- for (l = smart_data->priv->attrs; l != NULL; l = l->next) {
- GduSmartDataAttribute *a = l->data;
- if (gdu_smart_data_attribute_get_id (a) == id) {
- ret = g_object_ref (a);
- goto out;
- }
- }
-out:
- return ret;
-}
-
-GduSmartData *
-_gdu_smart_data_new (gpointer data)
-{
- GduSmartData *smart_data;
- GValue elem0 = {0};
- GPtrArray *attrs;
- int n;
-
- smart_data = GDU_SMART_DATA (g_object_new (GDU_TYPE_SMART_DATA, NULL));
-
- g_value_init (&elem0, HISTORICAL_SMART_DATA_STRUCT_TYPE);
- g_value_set_static_boxed (&elem0, data);
- dbus_g_type_struct_get (&elem0,
- 0, &(smart_data->priv->time_collected),
- 1, &(smart_data->priv->temperature),
- 2, &(smart_data->priv->time_powered_on),
- 3, &(smart_data->priv->last_self_test_result),
- 4, &(smart_data->priv->is_failing),
- 5, &attrs,
- G_MAXUINT);
-
- smart_data->priv->attrs = NULL;
- if (attrs != NULL) {
- for (n = 0; n < (int) attrs->len; n++) {
- smart_data->priv->attrs = g_list_prepend (smart_data->priv->attrs,
- _gdu_smart_data_attribute_new (attrs->pdata[n]));
- }
- smart_data->priv->attrs = g_list_reverse (smart_data->priv->attrs);
- }
-
- return smart_data;
-}
-
-GduSmartData *
-_gdu_smart_data_new_from_values (guint64 time_collected,
- double temperature,
- guint64 time_powered_on,
- const char *last_self_test_result,
- gboolean is_failing,
- GPtrArray *attrs)
-{
- GduSmartData *smart_data;
- int n;
-
- smart_data = GDU_SMART_DATA (g_object_new (GDU_TYPE_SMART_DATA, NULL));
- smart_data->priv->time_collected = time_collected;
- smart_data->priv->temperature = temperature;
- smart_data->priv->time_powered_on = time_powered_on;
- smart_data->priv->last_self_test_result = g_strdup (last_self_test_result);
- smart_data->priv->is_failing = is_failing;
-
- smart_data->priv->attrs = NULL;
- if (attrs != NULL) {
- for (n = 0; n < (int) attrs->len; n++) {
- smart_data->priv->attrs = g_list_prepend (smart_data->priv->attrs,
- _gdu_smart_data_attribute_new (attrs->pdata[n]));
- }
- smart_data->priv->attrs = g_list_reverse (smart_data->priv->attrs);
- }
- return smart_data;
-}
diff --git a/src/gdu/gdu-smart-data.h b/src/gdu/gdu-smart-data.h
deleted file mode 100644
index b5816b6..0000000
--- a/src/gdu/gdu-smart-data.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-/* gdu-smart-data.h
- *
- * Copyright (C) 2007 David Zeuthen
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-
-#if !defined (__GDU_INSIDE_GDU_H) && !defined (GDU_COMPILATION)
-#error "Only <gdu/gdu.h> can be included directly, this file may disappear or change contents."
-#endif
-
-#ifndef __GDU_SMART_DATA_H
-#define __GDU_SMART_DATA_H
-
-#include <gdu/gdu-types.h>
-
-G_BEGIN_DECLS
-
-#define GDU_TYPE_SMART_DATA (gdu_smart_data_get_type ())
-#define GDU_SMART_DATA(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDU_TYPE_SMART_DATA, GduSmartData))
-#define GDU_SMART_DATA_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), GDU_SMART_DATA, GduSmartDataClass))
-#define GDU_IS_SMART_DATA(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDU_TYPE_SMART_DATA))
-#define GDU_IS_SMART_DATA_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDU_TYPE_SMART_DATA))
-#define GDU_SMART_DATA_GET_CLASS(k) (G_TYPE_INSTANCE_GET_CLASS ((k), GDU_TYPE_SMART_DATA, GduSmartDataClass))
-
-typedef struct _GduSmartDataClass GduSmartDataClass;
-typedef struct _GduSmartDataPrivate GduSmartDataPrivate;
-
-struct _GduSmartData
-{
- GObject parent;
-
- /* private */
- GduSmartDataPrivate *priv;
-};
-
-struct _GduSmartDataClass
-{
- GObjectClass parent_class;
-
-};
-
-GType gdu_smart_data_get_type (void);
-guint64 gdu_smart_data_get_time_collected (GduSmartData *smart_data);
-double gdu_smart_data_get_temperature (GduSmartData *smart_data);
-guint64 gdu_smart_data_get_time_powered_on (GduSmartData *smart_data);
-char *gdu_smart_data_get_last_self_test_result (GduSmartData *smart_data);
-gboolean gdu_smart_data_get_is_failing (GduSmartData *smart_data);
-GList *gdu_smart_data_get_attributes (GduSmartData *smart_data);
-gboolean gdu_smart_data_get_attribute_warning (GduSmartData *smart_data);
-gboolean gdu_smart_data_get_attribute_failing (GduSmartData *smart_data);
-GduSmartDataAttribute *gdu_smart_data_get_attribute (GduSmartData *smart_data,
- int id);
-
-G_END_DECLS
-
-#endif /* __GDU_SMART_DATA_H */
diff --git a/src/gdu/gdu-types.h b/src/gdu/gdu-types.h
index b31054e..8e3c826 100644
--- a/src/gdu/gdu-types.h
+++ b/src/gdu/gdu-types.h
@@ -33,18 +33,18 @@ G_BEGIN_DECLS
/* forward type definitions */
-typedef struct _GduPool GduPool;
-typedef struct _GduDevice GduDevice;
-typedef struct _GduPresentable GduPresentable; /* Dummy typedef */
-typedef struct _GduDrive GduDrive;
-typedef struct _GduLinuxMdDrive GduLinuxMdDrive;
-typedef struct _GduVolume GduVolume;
-typedef struct _GduVolumeHole GduVolumeHole;
-
-typedef struct _GduKnownFilesystem GduKnownFilesystem;
-typedef struct _GduProcess GduProcess;
-typedef struct _GduSmartData GduSmartData;
-typedef struct _GduSmartDataAttribute GduSmartDataAttribute;
+typedef struct _GduPool GduPool;
+typedef struct _GduDevice GduDevice;
+typedef struct _GduPresentable GduPresentable; /* Dummy typedef */
+typedef struct _GduDrive GduDrive;
+typedef struct _GduLinuxMdDrive GduLinuxMdDrive;
+typedef struct _GduVolume GduVolume;
+typedef struct _GduVolumeHole GduVolumeHole;
+
+typedef struct _GduKnownFilesystem GduKnownFilesystem;
+typedef struct _GduProcess GduProcess;
+typedef struct _GduAtaSmartHistoricalData GduAtaSmartHistoricalData;
+typedef struct _GduAtaSmartAttribute GduAtaSmartAttribute;
G_END_DECLS
diff --git a/src/gdu/gdu.h b/src/gdu/gdu.h
index d4e8b9d..67aa4a2 100644
--- a/src/gdu/gdu.h
+++ b/src/gdu/gdu.h
@@ -37,8 +37,8 @@
#include <gdu/gdu-pool.h>
#include <gdu/gdu-presentable.h>
#include <gdu/gdu-process.h>
-#include <gdu/gdu-smart-data.h>
-#include <gdu/gdu-smart-data-attribute.h>
+#include <gdu/gdu-ata-smart-historical-data.h>
+#include <gdu/gdu-ata-smart-attribute.h>
#include <gdu/gdu-util.h>
#include <gdu/gdu-volume.h>
#include <gdu/gdu-volume-hole.h>