old-www/HOWTO/SCSI-Generic-HOWTO/sg3_utils.html

309 lines
5.6 KiB
HTML

<HTML
><HEAD
><TITLE
>Sg3_utils package</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="Asynchronous usage of sg"
HREF="async.html"><LINK
REL="NEXT"
TITLE="sg_header, the original sg control structure"
HREF="sg_header.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="async.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="sg_header.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="APPENDIX"
><H1
><A
NAME="SG3_UTILS">Appendix A. Sg3_utils package</H1
><P
>The sg3_utils package is a collection of programs that use the sg interface.
The utilities can be categorized as follows:
<P
></P
><UL
><LI
><P
>variants of the Unix <B
CLASS="COMMAND"
>dd</B
> command: sg_dd, sgp_dd, sgq_dd
and sgm_dd,</P
></LI
><LI
><P
>scanning and mapping utilities: sg_scan, sg_map and scsi_devfs_scan,</P
></LI
><LI
><P
>SCSI support: sg_inq, scsi_inquiry, sginfo, sg_readcap, sg_start and sg_reset,</P
></LI
><LI
><P
>timing and testing: sg_rbuf, sg_test_rwbuf, sg_read, sg_turs and sg_debug,</P
></LI
><LI
><P
>example programs: sg_simple1..4 and sg_simple16,</P
></LI
></UL
></P
><P
>The "dd" family of utilities take a sg device file name as input (i.e.
if=&#60;sg_dev_filen_name&#62;), as output of both. They can also take raw
device file names
<A
NAME="AEN804"
HREF="#FTN.AEN804"
>[1]</A
>
instead of sg device file names. One important difference from the
standard <B
CLASS="COMMAND"
>dd</B
> command is that the value given to
the block size (bs=) argument must be the exact block size of that device
and not a integral multiple as allowed by <B
CLASS="COMMAND"
>dd</B
>.
These "dd" variants are suitable for SCSI Direct Access Devices such
as disk and CDROMs (but are not suitable for SCSI tape devices).</P
><P
>The sg3_utils package is designed to be used with the sg version 3
driver found in the lk 2.4 series. There is also a sg_utils package
that supports a subset of these commands for the sg version 2 driver
(with some support for the original sg driver) which is found in
the lk 2.2 series (from and after lk 2.2.6). There are links to
the most recent sg3_utils (and sg_utils) packages at the sg website
at <A
HREF="http://www.torque.net/sg"
TARGET="_top"
>
<TT
CLASS="LITERAL"
>www.torque.net/sg</TT
></A
>. There are tarballs and
both source and binary rpm packages. At the time of writing the latest
sg3_utils tarball is at
<A
HREF="http://www.torque.net/sg/p/sg3_utils-0.97.tgz"
TARGET="_top"
>
<TT
CLASS="LITERAL"
>www.torque.net/sg/p/sg3_utils-0.97.tgz</TT
></A
>.
There is a README file in that tarball that should be examined for
up to date information. The more important utility commands (e.g.
sg_dd) have "man" pages.
<A
NAME="AEN816"
HREF="#FTN.AEN816"
>[2]</A
></P
><P
>Almost all of the sg device driver capabilities discussed in this
document appear in code in one or more of these programs. For example
the recently added mmap-ed IO can be found in sgm_dd, sg_read and
sg_rbuf.</P
><P
>The sg3_utils package also provides some functions that may be useful for
applications that use sg. The functions declared in <TT
CLASS="FILENAME"
>sg_err.h</TT
> and defined in <TT
CLASS="FILENAME"
>sg_err.c</TT
>
categorize SCSI subsystem errors that are returned to an application
in a read() or a ioctl(SG_IO). In the case of sense buffers, they
are decoded into text message (as per SCSI 2 definitions). There is
also a function to do a 64 bit seek (<TT
CLASS="FILENAME"
>llseek.h</TT
>).</P
></DIV
><H3
CLASS="FOOTNOTES"
>Notes</H3
><TABLE
BORDER="0"
CLASS="FOOTNOTES"
WIDTH="100%"
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN804"
HREF="sg3_utils.html#AEN804"
>[1]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>Raw device names are of the form <TT
CLASS="FILENAME"
>/dev/raw/raw&#60;n&#62;</TT
>
and can be bound to block devices (e.g. an IDE disk partition
such as <TT
CLASS="FILENAME"
>/dev/hda3</TT
>). The binding is done with the
<B
CLASS="COMMAND"
>raw</B
> command (see "man raw").</P
></TD
></TR
><TR
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="5%"
><A
NAME="FTN.AEN816"
HREF="sg3_utils.html#AEN816"
>[2]</A
></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
WIDTH="95%"
><P
>Although the author wrote most of these programs, initially to test
facilities within the sg driver, some have been contributed by others.
See <A
HREF="http://www.torque.net/sg/u_index.html"
TARGET="_top"
><TT
CLASS="LITERAL"
>www.torque.net/sg/u_index.html</TT
></A
>
for more information.</P
></TD
></TR
></TABLE
><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="async.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="sg_header.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Asynchronous usage of sg</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>sg_header, the original sg control structure</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>