diff options
author | Ondrej Čerman <ondrej.cerman@gmail.com> | 2020-12-12 14:23:23 +0100 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2020-12-12 11:58:05 -0800 |
commit | 0893af788fb5b4ed05adb8efee0697eb6c63f866 (patch) | |
tree | 7bb8951cbd465db604285da9a2ccf89524dc0f3a /hardinfo | |
parent | 74a0db7398cec5f05d703c9b52337e3ba8988c76 (diff) |
devices/storage: added intepreted s.m.a.r.t. value
Diffstat (limited to 'hardinfo')
-rw-r--r-- | hardinfo/udisks2_util.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/hardinfo/udisks2_util.c b/hardinfo/udisks2_util.c index e3cf255a..83f1abc9 100644 --- a/hardinfo/udisks2_util.c +++ b/hardinfo/udisks2_util.c @@ -474,7 +474,7 @@ gchar* get_udisks2_smart_attributes(udiskd* dsk, const char *drivepath){ GError *error = NULL; const char* aidenf; guint8 aid; - gint16 avalue, aworst, athreshold; + gint16 avalue, aworst, athreshold, pretty_unit; gint64 pretty; udisksa *lastp = NULL, *p; @@ -505,13 +505,43 @@ gchar* get_udisks2_smart_attributes(udiskd* dsk, const char *drivepath){ // id(y), identifier(s), flags(q), value(i), worst(i), threshold(i), // pretty(x), pretty_unit(i), expansion(a{sv}) - while (g_variant_iter_loop (iter, "(ysqiiixia{sv})", &aid, &aidenf, NULL, &avalue, &aworst, &athreshold, NULL, NULL, NULL)){ + // pretty_unit = 0 (unknown), 1 (dimensionless), 2 (milliseconds), 3 (sectors), 4 (millikelvin). + while (g_variant_iter_loop (iter, "(ysqiiixia{sv})", &aid, &aidenf, NULL, &avalue, + &aworst, &athreshold, &pretty, &pretty_unit, NULL)){ p = udisksa_new(); p->id = aid; p->identifier = g_strdup(aidenf); p->value = avalue; p->worst = aworst; p->threshold = athreshold; + switch (pretty_unit){ + case 1: + p->interpreted_unit = UDSK_INTPVAL_DIMENSIONLESS; + p->interpreted = pretty; + break; + case 2: + if (pretty > 1000*60*60){ // > 1h + p->interpreted_unit = UDSK_INTPVAL_HOURS; + p->interpreted = pretty / (1000*60*60); + } + else{ + p->interpreted_unit = UDSK_INTPVAL_MILISECONDS; + p->interpreted = pretty; + } + break; + case 3: + p->interpreted_unit = UDSK_INTPVAL_SECTORS; + p->interpreted = pretty; + break; + case 4: + p->interpreted_unit = UDSK_INTPVAL_CELSIUS; + p->interpreted = (pretty - 273150) / 1000; //mK to °C + break; + default: + p->interpreted_unit = UDSK_INTPVAL_SKIP; + p->interpreted = -1; + break; + } p->next = NULL; if (lastp == NULL) |