内核源代码中的以下头文件与 sg 驱动相关:
/usr/src/linux/include/scsi/sg.h |
正如在E.1 节中指出的,最好通过以下方式将其包含在应用程序中:
#include <linux/../scsi/sg.h> |
以下是 sg.h 文件中的一些定义,用户可能希望更改。 当前默认值显示在右侧的括号中:
SG_SCATTER_SZ {32768} SG_DEF_RESERVED_SIZE {SG_SCATTER_SZ} SG_DEF_FORCE_LOW_DMA {0} SG_DEF_FORCE_PACK_ID {0} SG_DEF_KEP_ORPHAN {0} SG_MAX_QUEUE {16} SG_DEFAULT_RETRIES {1} # i.e. don't retry SG_BIG_BUFF {SG_DEF_RESERVED_SIZE} SG_DEFAULT_TIMEOUT {60 seconds} SG_DEF_COMMAND_Q {0 *} SG_DEF_UNDERRUN_FLAG {0} * The per file descriptor copy of this flips to 1 (thus allowing command queuing) as soon as a write() based on the newer sg_io_hdr structure is detected. |
以下ioctl()按字母顺序列出,右侧有简要说明。[更多详情请参见 sg 文档。]
SG_EMULATED_HOST [indicate if adapter is ide-scsi] SG_GET_COMMAND_Q [command queuing flag state] SG_GET_KEEP_ORPHAN [interrupted SG_IO keep orphan flag state] SG_GET_LOW_DMA ["low dma flag" (<= 16 MB on i386) state] SG_GET_NUM_WAITING [number of responses waiting to be read()] SG_GET_PACK_ID [pack_id of next to read() response (-1 if none)] SG_GET_REQUEST_TABLE [yields array of requests being processed] SG_GET_RESERVED_SIZE [current size of reserved buffer] SG_GET_SCSI_ID [a little more info than the mid level's SCSI_IOCTL_GET_IDLUN ioctl] SG_GET_SG_TABLESIZE [max entries in host's scatter gather table] SG_GET_TIMEOUT [yields timeout (unit: jiffies (10ms on i386))] SG_GET_TRANSFORM [state of ide-scsi's transform flag] SG_IO [send given SCSI command and wait for response] SG_NEXT_CMD_LEN [change command length of next command] SG_SCSI_RESET [send a SCSI bus, device or host reset] SG_SET_COMMAND_Q [set command queuing state {old=0, new=1}] SG_SET_DEBUG [set debug level {0}] SG_SET_KEEP_ORPHAN [set SG_IO's keep orphan flag {0}] SG_SET_FORCE_LOW_DMA [force DMA buffer low (<= 16 MB on i386) {0}] SG_SET_FORCE_PACK_ID [so read() can fetch by pack_id {0}] SG_SET_RESERVED_SIZE [change default buffer size {SG_DEF_RESERVED_SIZE}] SG_SET_TIMEOUT [change current timeout {60 secs} ] SG_SET_TRANSFORM [set ide-scsi's ATAPI transform flag {0}] open() [recognized oflags: O_RDONLY, O_RDWR, O_EXCL, O_NONBLOCK] close() read() write() ioctl() poll() [used when in O_NONBLOCK mode] fasync() [enables generation of SIGIO signal for read()] |