Closed ZakDanger closed 5 months ago
I thought i should add that every Windows SPTI sample code I've seen calls DeviceIoControl(), then checks that the return value is True and that ScsiStatus is 0 to determine that the command was successful.
It is possible for DeviceIoControl() to return True, but SccsiStatus NOT be zero. In this case the command is treated as unsuccessful.
Here is one such example from the Windows Drive DevKit https://github.com/9176324/WinDDK/blob/master/7600.16385.1/src/storage/tools/spti/spti.c
The interface for issue_command
is going to change a bit, returning an object that has common universal fields (like status) as well as pointers to the platform-specific structs. That should take care of this. At a low level, we don't want to check statuses ourselves or raise exceptions if we can help it, but we should check this field in the higher level API.
Can you try the changes in main
?
Windows and Linux both support returning a status value for the scsi device after a scsi command is attempted. This is separate to the sense data and is not currently handled by smartie.
On Linux this value comes from 'SGIOHeader.status'. On Windows this value comes from 'SCSIPassThroughDirect.scsi_status'
The values returned by Windows and Linux are different, but they could be mapped onto matching values when returned by smartie. It looks like you aready have the Linux values in "scsi/structures.py" under "class StatusCode(enum.IntEnum):"
The values for Windows can be gotten from: https://github.com/9176324/WinDDK/blob/master/7600.16385.1/inc/ddk/scsi.h They are:
If you are already making changes to 'issue_command()' to return a tuple that now includes the data size, perhaps you could also add the scsi status to the tuple.