From 5e98164b6414e623f53765ec3d9207add5d309bd Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 16 Feb 2026 14:48:47 +0100 Subject: [PATCH] Log the real raw value of SMART temperature --- cmdline/support.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/cmdline/support.c b/cmdline/support.c index e68ec70e..bd5edfd6 100644 --- a/cmdline/support.c +++ b/cmdline/support.c @@ -1851,7 +1851,13 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, struct smart inside = 1; } else if (inside) { char id_name[128] = { 0 }; - if (sscanf(s, "%u %127s %*s %" SCNu64 " %" SCNu64 " %" SCNu64 " %*s %*s %*s %" SCNu64, &id, id_name, &norm, &worst, &thresh, &raw) != 6) { + uint64_t min, max; + int minmax; + if (sscanf(s, "%u %127s %*s %" SCNu64 " %" SCNu64 " %" SCNu64 " %*s %*s %*s %" SCNu64 " (Min/Max %" SCNu64 "/%" SCNu64 ")", &id, id_name, &norm, &worst, &thresh, &raw, &min, &max) == 8) { + minmax = 1; + } else if (sscanf(s, "%u %127s %*s %" SCNu64 " %" SCNu64 " %" SCNu64 " %*s %*s %*s %" SCNu64, &id, id_name, &norm, &worst, &thresh, &raw) == 6) { + minmax = 0; + } else { log_fatal(EEXTERNAL, "Invalid smartctl line '%s'.\n", s); return -1; } @@ -1863,6 +1869,15 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, struct smart /* LCOV_EXCL_STOP */ } + /* revert the min/max decoding done by smartctl */ + if (minmax + && raw <= 0xFFFFUL + && min <= 0xFFFFUL + && max <= 0xFFFFUL) { + raw |= min << 16; + raw |= max << 32; + } + smart[id].raw = raw; smart[id].norm = norm; smart[id].worst = worst;