As I learned from SCSI Commands Reference Manual, many scsi devices have a reserved place for custom logs. This is page 0xF - Application Client log page. So I'm looking for a way to write some data to that area.
At fist I tried to use sg_logs command, but didn't succeed. I'm not sure what is the problem in this case - either I give wrong flags to that command or the message I send is not correct. Man page of sg_logs says:
The Application Client log page has 64 log parameters with parameters codes 0 to 63.
Each can hold 252 bytes of user binary data. That 252 bytes (or less) of user data, with
a 4 byte prefix (for a total of 256 bytes) can be provided with the --in=FN option. A
typical prefix would be '0,n,83,fc'. The "n" is the parameter code in hex so the last log
parameter would be '0,3f,83,fc'. That log parameter could be read back at some later
time with '--page=0xf --filter=0x<n>'.
and I gave the following command:
sg_logs --in=- --page=0xf --select /dev/sda -s -vvv
0 0 83 fc aa bb cc dd
where aa bb cc dd
is what I want to be written to the log page.
I get the following information after this request and have no idea how to find what is the problem:
open /dev/sda with flags=0x802
inquiry cdb: 12 00 00 00 24 00
duration=0 ms
HGST HUH721212AL5204 C3D0
log select cdb: 4c 01 4f 00 00 00 00 00 08 00
log select parameter list
00 00 83 fc aa bb cc dd
duration=2 ms
log select:
Descriptor format, current; Sense key: Illegal Request
Additional sense: Invalid field in cdb
Descriptor type: Sense key specific: Field pointer:
Error in Command: byte 2 bit 5
Descriptor type: Field replaceable unit code: 0x0
Descriptor type: Vendor specific [0x80]
f8 23
Raw sense data (in hex):
72 05 24 00 00 00 00 10 02 06 00 00 cd 00 02 00
03 02 00 00 80 02 f8 23
It seems that I really have to go deep in understanding how scsi devices communicate and how cdb is constructed, but the SCSI Commands Reference Manual which I try to use as a guide seems to postulate everything in a very general manner and I have no idea where to search for solution of my problem.
I would be very grateful for any information concerning this issue.
From SPC-5 spec
If the PARAMETER LISTLENGTH fild is not zero,and PAGE CODE or SUBPAGE CODE is set to a value other than zero,then the device servers shall terminate the cmd with CHECK CONDITION stutus.
That is why you can not execute the log select cmd sucessfully.
so you should set PAGE CODE and SUBPAGE CODE to zero in log select CDB. And each log page has page/subpage code to identiy itself.
if you want to send one or more log parameter,also remember to make the parameter code value in ascending order.