diff --git a/smartmontools/ChangeLog b/smartmontools/ChangeLog index f6d5f3d98af5a327578d267a4032c5505f4d93ae..44f9811c8b536f2cefea095c22705897c7862d44 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 dab29baccc31607284cb380d82a5efa0a5728ad4..c5c55b48c09b4536d2bc36bb096ebad4adb7dd48 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];