From 226de01ba493453c954bd9ebb0a49a2f255b13f6 Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Mon, 28 Sep 2026 15:43:37 +0200 Subject: [PATCH] Report smartctl open failures as unknown power state --- cmdline/mingwapp.c | 11 ++++++++--- cmdline/unixapp.c | 11 ++++++++--- doc/snapraid_log.1 | 4 ++++ doc/snapraid_log.d | 4 ++++ doc/snapraid_log.txt | 4 ++++ 5 files changed, 28 insertions(+), 6 deletions(-) diff --git a/cmdline/mingwapp.c b/cmdline/mingwapp.c index e19cb97e..79103e11 100644 --- a/cmdline/mingwapp.c +++ b/cmdline/mingwapp.c @@ -1750,12 +1750,17 @@ retry: log_tag("attr:%s:%s:power:standby\n", file, name); *power = POWER_STANDBY; } else { - log_tag("attr:%s:%s:power:active\n", file, name); - *power = POWER_ACTIVE; - /* store the smartctl return value */ if (smart) smart[SMART_FLAGS].raw = WEXITSTATUS(ret); + + if (WEXITSTATUS(ret) & SMARTCTL_FLAG_OPEN) { + log_tag("attr:%s:%s:power:unknown\n", file, name); + *power = POWER_UNKNOWN; + } else { + log_tag("attr:%s:%s:power:active\n", file, name); + *power = POWER_ACTIVE; + } } return 0; diff --git a/cmdline/unixapp.c b/cmdline/unixapp.c index 357e3f99..a7373078 100644 --- a/cmdline/unixapp.c +++ b/cmdline/unixapp.c @@ -3797,12 +3797,17 @@ static int devprobe(dev_t device, const char* name, const char* smartctl, const log_tag("attr:%s:%s:power:standby\n", file, name); *power = POWER_STANDBY; } else { - log_tag("attr:%s:%s:power:active\n", file, name); - *power = POWER_ACTIVE; - /* store the smartctl return value */ if (smart) smart[SMART_FLAGS].raw = WEXITSTATUS(ret); + + if (WEXITSTATUS(ret) & SMARTCTL_FLAG_OPEN) { + log_tag("attr:%s:%s:power:unknown\n", file, name); + *power = POWER_UNKNOWN; + } else { + log_tag("attr:%s:%s:power:active\n", file, name); + *power = POWER_ACTIVE; + } } return 0; diff --git a/doc/snapraid_log.1 b/doc/snapraid_log.1 index fb3d2b5d..403065a0 100644 --- a/doc/snapraid_log.1 +++ b/doc/snapraid_log.1 @@ -1866,6 +1866,10 @@ read. Logs a successful spin\-down operation initiated via the smartctl command. .TP +.B attr::[/]:power:unknown +Logs that the device power state could not be determined +after a status probe. +.TP .B stat:: Logs the total number of read and write accesses done on the disk. This is a cumulative value that include all the devices diff --git a/doc/snapraid_log.d b/doc/snapraid_log.d index bcdc2546..3ce80829 100644 --- a/doc/snapraid_log.d +++ b/doc/snapraid_log.d @@ -1170,6 +1170,10 @@ Command Smart And Probe Tags Logs a successful spin-down operation initiated via the smartctl command. + =attr::[/]:power:unknown + Logs that the device power state could not be determined + after a status probe. + =stat:: Logs the total number of read and write accesses done on the disk. This is a cumulative value that include all the devices diff --git a/doc/snapraid_log.txt b/doc/snapraid_log.txt index 39cf518a..0dca77c2 100644 --- a/doc/snapraid_log.txt +++ b/doc/snapraid_log.txt @@ -1216,6 +1216,10 @@ Tags logging specific disk identification and attribute values. Logs a successful spin-down operation initiated via the smartctl command. + attr::[/]:power:unknown + Logs that the device power state could not be determined + after a status probe. + stat:: Logs the total number of read and write accesses done on the disk. This is a cumulative value that include all the devices