CLASS="CHAPTER" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" >

Chapter 8. Ioctl()s

Table of Contents
8.1. SG_IO
8.2. SG_GET_ACCESS_COUNT
8.3. SG_SET_COMMAND_Q (and _GET_)
8.4. SG_SET_DEBUG
8.5. SG_EMULATED_HOST
8.6. SG_SET_KEEP_ORPHAN (and _GET_)
8.7. SG_SET_FORCE_LOW_DMA
8.8. SG_GET_LOW_DMA
8.9. SG_NEXT_CMD_LEN
8.10. SG_GET_NUM_WAITING
8.11. SG_SET_FORCE_PACK_ID
8.12. SG_GET_PACK_ID
8.13. SG_GET_REQUEST_TABLE
8.14. SG_SET_RESERVED_SIZE (and _GET_ )
8.15. SG_SCSI_RESET
8.16. SG_GET_SCSI_ID
8.17. SG_GET_SG_TABLESIZE
8.18. SG_GET_TIMEOUT
8.19. SG_SET_TIMEOUT
8.20. SG_SET_TRANSFORM
8.21. SG_GET_TRANSFORM
8.22. Sg ioctls removed in version 3
8.23. SCSI_IOCTL_GET_IDLUN
8.24. SCSI_IOCTL_GET_PCI
8.25. SCSI_IOCTL_PROBE_HOST
8.26. SCSI_IOCTL_SEND_COMMAND

The Linux SCSI upper level drivers, including sg, have a "trickle down" ioctl() architecture. This means that ioctl()s whose request value (i.e. the second argument) is not understood by the upper level driver, are passed down to the SCSI mid-level. Those ioctl()s that are not understood by the mid level driver are passed down to the lower level (adapter) driver. If none of the 3 levels understands the ioctl() request value then -1 is returned and EINVAL is placed in errno. By convention the beginning of the request value's symbolic name indicates which level will respond to the ioctl(). For example, request values starting with "SG_" are processed by the sg driver while those starting with "SCSI_" are processed by the mid level.

Most of the sg ioctl()s read or write information via a pointer given as the third argument to the ioctl() call and return 0 on success. A few of the older ioctl()s that get a value from the driver return that value as the result of the ioctl() call (e.g. ioctl(SG_GET_TIMEOUT) ).

All sg driver ioctl()s are listed below. They all start with "SG_". They are followed by several interesting SCSI mid level ioctl()s which start with "SCSI_IOCTL_". The sg ioctl()s are roughly in alphabetical order (with _SET_, _GET_ and _FORCE_ ignored). Since ioctl(SG_IO) is a complete SCSI command request/response sequence then it is listed first.