smartmontools/SOURCES/smartmontools-7.2-logsuppagefix1.patch
2023-09-27 14:13:01 +00:00

86 lines
3.2 KiB
Diff

From da45fc39390208c30b3ba656ccfb478e217b7401 Mon Sep 17 00:00:00 2001
From: "Milan P. Gandhi" <mgandhi@redhat.com>
Date: Mon, 17 Oct 2022 14:23:54 +0530
Subject: [PATCH 1/3] scsiprint.cpp: Attempted fix to tickets 1272, 1331 and
1346: Log sub-page handling
---
smartmontools-7.1/scsiprint.cpp | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/smartmontools-7.1/scsiprint.cpp b/smartmontools-7.1/scsiprint.cpp
index 4c52268..1edb7c2 100644
--- a/smartmontools-7.1/scsiprint.cpp
+++ b/smartmontools-7.1/scsiprint.cpp
@@ -118,8 +118,10 @@ static void
scsiGetSupportedLogPages(scsi_device * device)
{
bool got_subpages = false;
- int k, bump, err, payload_len, num_unreported, num_unreported_spg;
- int payload_len_pg0_0 = 0;
+ int k, bump, err, resp_len, num_unreported, num_unreported_spg;
+ int resp_len_pg0_0 = 0;
+ int resp_len_pg0_ff = 0; /* in SPC-4, response length of supported
+ * log pages _and_ log subpages */
const uint8_t * up;
uint8_t sup_lpgs[LOG_RESP_LEN];
@@ -143,7 +145,7 @@ scsiGetSupportedLogPages(scsi_device * device)
(scsi_version <= SCSI_VERSION_HIGHEST)) {
/* unclear what code T10 will choose for SPC-6 */
memcpy(sup_lpgs, gBuf, LOG_RESP_LEN);
- payload_len_pg0_0 = sup_lpgs[3];
+ resp_len_pg0_0 = sup_lpgs[3];
if ((err = scsiLogSense(device, SUPPORTED_LPAGES, SUPP_SPAGE_L_SPAGE,
gBuf, LOG_RESP_LONG_LEN,
-1 /* just single not double fetch */))) {
@@ -160,33 +162,38 @@ scsiGetSupportedLogPages(scsi_device * device)
if (scsi_debugmode > 0)
pout("%s supported subpages is bad SPF=%u SUBPG=%u\n",
logSenRspStr, !! (0x40 & gBuf[0]), gBuf[2]);
- } else
+ } else {
+ resp_len_pg0_ff = sg_get_unaligned_be16(gBuf + 2);
got_subpages = true;
+ }
}
- } else
+ } else {
memcpy(sup_lpgs, gBuf, LOG_RESP_LEN);
+ resp_len_pg0_0 = sup_lpgs[3];
+ }
if (got_subpages) {
- payload_len = sg_get_unaligned_be16(gBuf + 2);
- if (payload_len <= payload_len_pg0_0) {
+ resp_len = sg_get_unaligned_be16(gBuf + 2);
+ if (resp_len_pg0_ff <= resp_len_pg0_0) {
/* something is rotten ....., ignore SUPP_SPAGE_L_SPAGE */
- payload_len = payload_len_pg0_0;
+ resp_len = resp_len_pg0_0;
bump = 1;
up = sup_lpgs + LOGPAGEHDRSIZE;
got_subpages = false;
(void)got_subpages; // not yet used below, suppress warning
} else {
+ resp_len = resp_len_pg0_ff;
bump = 2;
up = gBuf + LOGPAGEHDRSIZE;
}
} else {
- payload_len = payload_len_pg0_0;
+ resp_len = resp_len_pg0_0;
bump = 1;
up = sup_lpgs + LOGPAGEHDRSIZE;
}
num_unreported_spg = 0;
- for (num_unreported = 0, k = 0; k < payload_len; k += bump, up += bump) {
+ for (num_unreported = 0, k = 0; k < resp_len; k += bump, up += bump) {
uint8_t pg_num = 0x3f & up[0];
uint8_t sub_pg_num = (0x40 & up[0]) ? up[1] : 0;
--
2.35.1