Report smartctl open failures as unknown power state
Some checks are pending
Build / build-mac (push) Waiting to run
Build / build-linux (push) Waiting to run
Build / build-arm32 (push) Waiting to run
Build / build-win (push) Waiting to run
Build / build-freebsd (push) Waiting to run
Build / build-musl (push) Waiting to run
CodeQL Advanced / Analyze (c-cpp) (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run

This commit is contained in:
Andrea Mazzoleni 2026-09-28 15:43:37 +02:00
parent 720073d80d
commit 226de01ba4
5 changed files with 28 additions and 6 deletions

View file

@ -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;

View file

@ -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;

View file

@ -1866,6 +1866,10 @@ read.
Logs a successful spin\-down operation initiated via the
smartctl command.
.TP
.B attr:<device_file>:<disk_name>[/<split_index>]:power:unknown
Logs that the device power state could not be determined
after a status probe.
.TP
.B stat:<disk_name>:<access_number>
Logs the total number of read and write accesses done on the
disk. This is a cumulative value that include all the devices

View file

@ -1170,6 +1170,10 @@ Command Smart And Probe Tags
Logs a successful spin-down operation initiated via the
smartctl command.
=attr:<device_file>:<disk_name>[/<split_index>]:power:unknown
Logs that the device power state could not be determined
after a status probe.
=stat:<disk_name>:<access_number>
Logs the total number of read and write accesses done on the
disk. This is a cumulative value that include all the devices

View file

@ -1216,6 +1216,10 @@ Tags logging specific disk identification and attribute values.
Logs a successful spin-down operation initiated via the
smartctl command.
attr:<device_file>:<disk_name>[/<split_index>]:power:unknown
Logs that the device power state could not be determined
after a status probe.
stat:<disk_name>:<access_number>
Logs the total number of read and write accesses done on the
disk. This is a cumulative value that include all the devices