Fix parsing sense data
Brought to you by:
ideguy
I have modern external WD 5 TB HDD. I have error (SG_IO: bad/missing sense data), because hdparm incorrectly parse sense data. This patch solve issue.
Spec: https://vdoc.pub/documents/scsi-ata-translation-5-sat-5-r01a-6dgve9kae3t0
$ sudo hdparm -S60 --verbose /dev/sda
/dev/sda:
APT: USB ID = 0x1058:0x2667 (0x2007)
APT: Unsupported device
setting standby to 60 (5 minutes)
outgoing cdb: 85 06 20 00 00 00 3c 00 00 00 00 00 00 40 e3 00
SG_IO: ATA_16 status=0x2, host_status=0x0, driver_status=0x8
SG_IO: sb[]: f0 00 01 00 50 40 3c 0a 80 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: bad/missing sense data, sb[]: f0 00 01 00 50 40 3c 0a 80 00 00 00 00 1d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
SG_IO: desc[]: 80 00
ATA_16 stat=00 err=00 nsect=1d lbal=00 lbam=00 lbah=00 dev=00
Parsing in other software: https://github.com/doug-gilbert/sg3_utils/blob/main/lib/sg_lib.c#L1840
Note about incorrect byte order i fixed there: https://github.com/doug-gilbert/sg3_utils/pull/25