189 lines
3.5 KiB
HTML
189 lines
3.5 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>sg_header, the original sg control structure</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
|
|
"><LINK
|
|
REL="HOME"
|
|
TITLE="The Linux SCSI Generic (sg) HOWTO"
|
|
HREF="index.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Sg3_utils package"
|
|
HREF="sg3_utils.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Programming example"
|
|
HREF="pexample.html"></HEAD
|
|
><BODY
|
|
CLASS="APPENDIX"
|
|
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 SCSI Generic (sg) HOWTO</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="sg3_utils.html"
|
|
ACCESSKEY="P"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
></TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="pexample.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="APPENDIX"
|
|
><H1
|
|
><A
|
|
NAME="SG_HEADER">Appendix B. sg_header, the original sg control structure</H1
|
|
><P
|
|
>Following is the original interface structure of the sg driver that
|
|
dates back to 1991. Those field elements with a "[o]+" are added by
|
|
the sg version 2 driver which was first placed in lk 2.2.6 in April
|
|
1999.
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><FONT
|
|
COLOR="#000000"
|
|
><PRE
|
|
CLASS="PROGRAMLISTING"
|
|
>struct sg_header
|
|
{
|
|
int pack_len; /* [o] */
|
|
int reply_len; /* [i] */
|
|
int pack_id; /* [i->o] */
|
|
int result; /* [o] */
|
|
unsigned int twelve_byte:1; /* [i] */
|
|
unsigned int target_status:5; /* [o]+ */
|
|
unsigned int host_status:8; /* [o]+ */
|
|
unsigned int driver_status:8; /* [o]+ */
|
|
unsigned int other_flags:10; /* unused */
|
|
unsigned char sense_buffer[SG_MAX_SENSE]; /* [o] */
|
|
}; /* This structure is 36 bytes long on i386 */</PRE
|
|
></FONT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
SCSI commands are sent via write() calls to an sg device name (e.g. /dev/sg0).
|
|
The data written to write() is of the form
|
|
<a_sg_header_obj + scsi_command [ + data_to_write]>. The "data_to_write"
|
|
component is only needed for SCSI commands that transfer data towards the
|
|
SCSI device. The corresponding read() to the sg device name will yield
|
|
data of the form <a_sg_header_obj [ + data_to_read]>.</P
|
|
><P
|
|
>This interface is fully described in the
|
|
<A
|
|
HREF="http://www.torque.net/sg/p/scsi-generic.txt"
|
|
TARGET="_top"
|
|
><TT
|
|
CLASS="LITERAL"
|
|
>www.torque.net/sg/p/scsi-generic.txt</TT
|
|
></A
|
|
>
|
|
file which documents the sg version 2 driver.</P
|
|
><P
|
|
>Since many Linux applications use this interface, it is still supported
|
|
in this version (i.e. version 3) of the driver. Only its most perverse
|
|
idiosyncrasies have been modified and no major applications have reported
|
|
any problems running old applications atop this newer driver.</P
|
|
></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="sg3_utils.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="pexample.html"
|
|
ACCESSKEY="N"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Sg3_utils package</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
> </TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Programming example</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |