mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-26 19:01:57 -04:00
Always trim family/serial/model
This commit is contained in:
parent
94e71365b8
commit
a7cae2707f
2 changed files with 14 additions and 5 deletions
|
|
@ -1766,15 +1766,18 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, uint64_t* sm
|
|||
}
|
||||
}
|
||||
} else if (sscanf(s, "Model Family: %63[^\n]", family) == 1) {
|
||||
strtrim(family);
|
||||
} else if (sscanf(s, "Device Model: %63[^\n]", model) == 1) {
|
||||
strtrim(model);
|
||||
} else if (sscanf(s, "Serial number: %63s", serial) == 1) {
|
||||
strtrim(serial);
|
||||
/* SCSI */
|
||||
} else if (sscanf(s, "Serial number: %63s", serial) == 1) { /* note "n" of "number" lower case */
|
||||
} else if (sscanf(s, "Elements in grown defect list: %" SCNu64, &smart[SMART_REALLOCATED_SECTOR_COUNT]) == 1) {
|
||||
} else if (sscanf(s, "Current Drive Temperature: %" SCNu64, &smart[SMART_TEMPERATURE_CELSIUS]) == 1) {
|
||||
} else if (sscanf(s, "Drive Trip Temperature: %" SCNu64, &smart[SMART_AIRFLOW_TEMPERATURE_CELSIUS]) == 1) {
|
||||
} else if (sscanf(s, "Accumulated start-stop cycles: %" SCNu64, &smart[SMART_START_STOP_COUNT]) == 1) {
|
||||
} else if (sscanf(s, "Accumulated load-unload cycles: %" SCNu64, &smart[SMART_LOAD_CYCLE_COUNT]) == 1) {
|
||||
} else if (sscanf(s, " number of hours powered up = %" SCNu64, &smart[SMART_POWER_ON_HOURS]) == 1) {
|
||||
} else if (sscanf(s, " number of hours powered up = %" SCNu64, &smart[SMART_POWER_ON_HOURS]) == 1) { /* note "n" of "number" lower case */
|
||||
/* ATA */
|
||||
} else if (sscanf(s, "Serial Number: %63s", serial) == 1) {
|
||||
} else if (smatch(s, "ID#") == 0) {
|
||||
|
|
|
|||
|
|
@ -1387,15 +1387,19 @@ static void devattr(dev_t device, uint64_t* info, char* serial, char* family, ch
|
|||
if (*model == 0) {
|
||||
pathprint(path, sizeof(path), "/sys/dev/block/%u:%u/device/model", major(device), minor(device));
|
||||
attr = sysattr(path, buf, sizeof(buf));
|
||||
if (attr && *attr)
|
||||
if (attr && *attr) {
|
||||
pathcpy(model, SMART_MAX, attr);
|
||||
strtrim(model);
|
||||
}
|
||||
}
|
||||
|
||||
if (*serial == 0) {
|
||||
pathprint(path, sizeof(path), "/sys/dev/block/%u:%u/device/serial", major(device), minor(device));
|
||||
attr = sysattr(path, buf, sizeof(buf));
|
||||
if (attr && *attr)
|
||||
if (attr && *attr) {
|
||||
pathcpy(serial, SMART_MAX, attr);
|
||||
strtrim(serial);
|
||||
}
|
||||
}
|
||||
|
||||
if (*serial == 0) {
|
||||
|
|
@ -1408,8 +1412,10 @@ static void devattr(dev_t device, uint64_t* info, char* serial, char* family, ch
|
|||
attr = buf + 4;
|
||||
attr[len] = 0;
|
||||
strtrim(attr);
|
||||
if (*attr)
|
||||
if (*attr) {
|
||||
pathcpy(serial, SMART_MAX, attr);
|
||||
strtrim(serial);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue