From acab7d5ac19dd0b0e047f7bc69c0e87d0cbb4057 Mon Sep 17 00:00:00 2001 From: dpgilbert <dpgilbert@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Tue, 17 Oct 2023 04:26:48 +0000 Subject: [PATCH] scsiprint.cpp : Format status indicates no format since manufacture git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk@5556 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/ChangeLog | 12 ++++++++++++ smartmontools/scsiprint.cpp | 37 ++++++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog index f6d5f3d98..44f9811c8 100644 --- a/smartmontools/ChangeLog +++ b/smartmontools/ChangeLog @@ -1,5 +1,17 @@ $Id$ +2023-10-16 Douglas Gilbert <dgilbert@interlog.com> + + scsiprint.cpp : most SCSI disks do not get formatted in their + lifetime. The Format status lpage is present on most recent disks + and is checked when the --xall option is given. In the common case + where a format has been performed (since manufacture) this leads + to 5 lines of <not available> output starting with: + Grown defects during certification <not available> + Detect this situation before printing any of those 5 lines + and replace those 5 lines with 1 line: + Format status indicates no format since manufacture + 2023-10-12 Douglas Gilbert <dgilbert@interlog.com> scsiprint.cpp : misplaced else corrupted the output of the Format diff --git a/smartmontools/scsiprint.cpp b/smartmontools/scsiprint.cpp index dab29bacc..c5c55b48c 100644 --- a/smartmontools/scsiprint.cpp +++ b/smartmontools/scsiprint.cpp @@ -2184,7 +2184,8 @@ scsiPrintTapeDeviceStats(scsi_device * device) static int scsiPrintFormatStatus(scsi_device * device) { - int num, err, truncated; + bool all_not_avail = false; + int num, num_hold, err, truncated; int retval = 0; uint64_t ull; uint8_t * ucp; @@ -2217,6 +2218,40 @@ scsiPrintFormatStatus(scsi_device * device) num = LOG_RESP_LONG_LEN; ucp = gBuf + 4; num -= 4; + num_hold = num; + + if (scsi_debugmode == 0) { + all_not_avail = true; + while (num > 3) { + int pc = sg_get_unaligned_be16(ucp + 0); + int pl = ucp[3] + 4; + + switch (pc) { + case 0: + break; + case 1: + case 2: + case 3: + case 4: + if (! all_ffs(ucp + 4, ucp[3])) + all_not_avail = false; + break; + default: + break; + } + if (! all_not_avail) + break; + num -= pl; + ucp += pl; + } + if (all_not_avail) { + jout("Format status indicates no format since manufacture\n"); + return retval; + } + num = num_hold; + ucp = gBuf + 4; + } + while (num > 3) { int pc = sg_get_unaligned_be16(ucp + 0); // pcb = ucp[2]; -- GitLab