Fix importing of serial from smartctl

This commit is contained in:
Andrea Mazzoleni 2026-03-20 11:14:19 +01:00
parent ef3572ea73
commit 2b6281cd81
2 changed files with 9 additions and 1 deletions

View file

@ -2569,6 +2569,12 @@ static void devattr_property(HANDLE h, char* serial, char* model, char* inter)
}
if (serial && *serial == 0 && desc->SerialNumberOffset) {
/*
* This is the RAW serial, maybe HEX encoded, maybe BYTES SWAPPED
* but we don't care because we just need any identifier
*
* If smartctl was not able to read it, we now accept anything
*/
snprintf(serial, SMART_MAX, "%s", (char*)(buffer + desc->SerialNumberOffset));
strtrim(serial);
}

View file

@ -1985,7 +1985,9 @@ int smartctl_attribute(FILE* f, const char* file, const char* name, struct smart
strtrim(family);
} else if (sscanf(s, "Device Model: %63[^\n]", model) == 1) {
strtrim(model);
} else if (sscanf(s, "Serial number: %63s", serial) == 1) {
} else if (sscanf(s, "Serial number: %63s", serial) == 1) { /* SCSI */
strtrim(serial);
} else if (sscanf(s, "Serial Number: %63s", serial) == 1) { /*ATA / NVMe */
strtrim(serial);
/* SCSI */
/*