I'm trying to port a Windows SCSI API over to Linux. The API has several functions, most of them using ATA_PASS_THROUGH_EX to send a vendor specific command over to the device. I've managed to port 1 of the API function that is a modified INQUIRY command. However, I'm very confused as to how ATA passthrough is done in Linux. I've looked at the sg3_utils source code to get some inspiration but it's too complicated for me to understand what's going on.

Does anyone know how to port this?

In Windows a ATA_PASS_THROUGH_EX pointer is declared and memory allocated for it. It's fields are then initialized(Length, AtaFlags, DataTransferLength, TimeOutValue, DataBufferOffset, CurrentTaskFile[], PreviousTaskFile[], etc) and then a DeviceIoControl() is called.

Now I know Linux's version of DeviceIoControl is ioctl() and I've used it successfully for the INQUIRY command, but what's Linux's version of ATA_PASS_THROUGH_EX?

Any help would be appreciated. Thanks!