Skip to content

Commit

Permalink
scsiprint.cpp : Format status indicates no format since manufacture
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.code.sf.net/p/smartmontools/code/trunk/smartmontools@5556 4ea69e1a-61f1-4043-bf83-b5c94c648137
  • Loading branch information
dpgilbert committed Oct 17, 2023
1 parent 90eff62 commit 5296a7f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
12 changes: 12 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
$Id$

2023-10-16 Douglas Gilbert <[email protected]>

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 <[email protected]>

scsiprint.cpp : misplaced else corrupted the output of the Format
Expand Down
37 changes: 36 additions & 1 deletion scsiprint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 5296a7f

Please sign in to comment.