<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML ><HEAD ><TITLE >sg driver</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="The Linux 2.4 SCSI subsystem HOWTO" HREF="index.html"><LINK REL="UP" TITLE="Compile options and System calls including ioctls" HREF="compileopt.html"><LINK REL="PREVIOUS" TITLE="st driver" HREF="cost.html"><LINK REL="NEXT" TITLE="References, Credits and Corrections" HREF="refs.html"></HEAD ><BODY CLASS="sect1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >The Linux 2.4 SCSI subsystem HOWTO</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="cost.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Appendix E. Compile options and System calls including ioctls</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="refs.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="cosg" ></A >E.5. sg driver</H1 ><P > The following header files in the kernel source are relevant to the sg driver: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="programlisting" > /usr/src/linux/include/scsi/sg.h </PRE ></FONT ></TD ></TR ></TABLE > </P ><P > As pointed out in <A HREF="coml.html" >Section E.1</A > this is best included in applications by using: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="programlisting" > #include <linux/../scsi/sg.h> </PRE ></FONT ></TD ></TR ></TABLE > </P ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="cosgco" ></A >E.5.1. sg compile options</H2 ><P > Here are some defines from the sg.h file that the user could conceivably want to change. The current default values are shown in braces on the right: <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="programlisting" > 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. </PRE ></FONT ></TD ></TR ></TABLE > </P ></DIV ><DIV CLASS="sect2" ><H2 CLASS="sect2" ><A NAME="cosgio" ></A >E.5.2. sg ioctls and user interface</H2 ><P > The following ioctl()s are listed in alphabetical order with a brief explanation to the right. [See sg documentation for more details.] <TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><FONT COLOR="#000000" ><PRE CLASS="programlisting" > 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()] </PRE ></FONT ></TD ></TR ></TABLE > </P ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="cost.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="refs.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >st driver</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="compileopt.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >References, Credits and Corrections</TD ></TR ></TABLE ></DIV ></BODY ></HTML >