8.26. SCSI_IOCTL_SEND_COMMAND

SCSI_IOCTL_SEND_COMMAND 0x1. 这个 ioctl() 也提供了一种“直通” SCSI 命令功能,它是 sg 驱动程序提供的功能的子集。

我们传递的结构应该如下所示
   struct sdata {
    unsigned int inlen;     [i] Length of data written to device
    unsigned int outlen;    [i] Length of data read from device
    unsigned char cmd[x];   [i] SCSI command (6 <= x <= 16)
                            [o] Data read from device starts here
                            [o] On error, sense buffer starts here
    unsigned char wdata[y]; [i] Data written to device starts here
   };
注释

注释

[1]

以下是从 SCSI 操作码“组”(操作码的最高 3 位)到假定长度的映射(在 lk 2.4.15 中)
unsigned char scsi_command_size[8] =
{
        6, 10, 10, 12,
        16, 12, 10, 10
};
在 lk 2.4.15 中,组 4 命令的假定长度从 12 更改为 16,这反映了内核中添加了对 16 字节 SCSI 命令的支持。