zpcictl: Use actual instead of max length in SCLP report

The SCLP report currently always uses the maximum length even if no
extra data is proved at all. Instead use the actual length of either
just the timestamp and err_log_id or additionally the length of sdata.

Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Niklas Schnelle
2024-12-05 15:05:11 +01:00
committed by Jan Höppner
parent 3a4c20b443
commit 4ec33d0b76

View File

@@ -9,6 +9,7 @@
#include <errno.h>
#include <fcntl.h>
#include <stddef.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
#include <time.h>
@@ -333,15 +334,15 @@ static void sclp_issue_action(struct zpci_device *pdev, int action)
report.header.version = 1;
report.header.action = action;
report.header.length = sizeof(report.data);
report.header.length = offsetof(struct zpci_report_error_data, log_data);
report.data.timestamp = (__u64)time(NULL);
report.data.err_log_id = 0x4713;
if (pdev->class == PCI_CLASS_NVME)
sdata = collect_smart_data(pdev);
if (sdata) {
util_strlcpy(report.data.log_data, sdata,
sizeof(report.data.log_data));
report.header.length += util_strlcpy(report.data.log_data, sdata,
sizeof(report.data.log_data));
free(sdata);
}
sysfs_report_error(&report, pdev->slot);