mirror of
https://github.com/amadvance/snapraid.git
synced 2026-12-01 12:26:38 -05:00
Log all the smartctl output
This commit is contained in:
parent
258ab45eef
commit
db3c417481
4 changed files with 111 additions and 27 deletions
|
|
@ -639,7 +639,7 @@ static int devsmart(dev_t device, const char* name, const char* custom, uint64_t
|
|||
snprintf(cmd, sizeof(cmd), "smartctl -a %s", file);
|
||||
}
|
||||
|
||||
msg_tag("smartctl:run:%s: %s\n", name, cmd);
|
||||
msg_tag("smartctl:%s:%s:run: %s\n", file, name, cmd);
|
||||
|
||||
f = popen(cmd, "r");
|
||||
if (!f) {
|
||||
|
|
@ -649,7 +649,7 @@ static int devsmart(dev_t device, const char* name, const char* custom, uint64_t
|
|||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (smartctl_attribute(f, smart, serial) != 0) {
|
||||
if (smartctl_attribute(f, file, name, smart, serial) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
pclose(f);
|
||||
return -1;
|
||||
|
|
@ -658,7 +658,7 @@ static int devsmart(dev_t device, const char* name, const char* custom, uint64_t
|
|||
|
||||
ret = pclose(f);
|
||||
|
||||
msg_tag("smartctl:ret:%s %x\n", name, ret);
|
||||
msg_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
|
||||
|
||||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
|
|
@ -687,6 +687,7 @@ static int devdown(dev_t device, const char* name, const char* custom)
|
|||
{
|
||||
char cmd[128];
|
||||
char file[128];
|
||||
FILE* f;
|
||||
int ret;
|
||||
|
||||
snprintf(file, sizeof(file), "/dev/block/%u:%u", major(device), minor(device));
|
||||
|
|
@ -695,23 +696,32 @@ static int devdown(dev_t device, const char* name, const char* custom)
|
|||
if (custom[0]) {
|
||||
char option[128];
|
||||
snprintf(option, sizeof(option), custom, file);
|
||||
snprintf(cmd, sizeof(cmd), "smartctl -s standby,now %s >/dev/null 2>/dev/null", option);
|
||||
snprintf(cmd, sizeof(cmd), "smartctl -s standby,now %s", option);
|
||||
} else {
|
||||
snprintf(cmd, sizeof(cmd), "smartctl -s standby,now %s >/dev/null 2>/dev/null", file);
|
||||
snprintf(cmd, sizeof(cmd), "smartctl -s standby,now %s", file);
|
||||
}
|
||||
|
||||
msg_tag("smartctl:run:%s: %s\n", name, cmd);
|
||||
msg_tag("smartctl:%s:%s:run: %s\n", file, name, cmd);
|
||||
|
||||
ret = system(cmd);
|
||||
|
||||
msg_tag("smartctl:ret:%s: %x\n", name, ret);
|
||||
|
||||
if (ret == -1) {
|
||||
f = popen(cmd, "r");
|
||||
if (!f) {
|
||||
/* LCOV_EXCL_START */
|
||||
msg_error("Failed to run '%s' (from system).\n", cmd);
|
||||
msg_error("Failed to run '%s' (from popen).\n", cmd);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
if (smartctl_flush(f, file, name) != 0) {
|
||||
/* LCOV_EXCL_START */
|
||||
pclose(f);
|
||||
return -1;
|
||||
/* LCOV_EXCL_STOP */
|
||||
}
|
||||
|
||||
ret = pclose(f);
|
||||
|
||||
msg_tag("smartctl:%s:%s:ret: %x\n", file, name, ret);
|
||||
|
||||
if (!WIFEXITED(ret)) {
|
||||
/* LCOV_EXCL_START */
|
||||
msg_error("Failed to run '%s' (not exited).\n", cmd);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue