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

206 lines
3.1 KiB
HTML

<HTML
><HEAD
><TITLE
>System calls</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="info"
HREF="x364.html"><LINK
REL="NEXT"
TITLE="open()"
HREF="open.html"></HEAD
><BODY
CLASS="CHAPTER"
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="x364.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="open.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="CHAPTER"
><H1
><A
NAME="SYSCALLS">Chapter 7. System calls</H1
><DIV
CLASS="TOC"
><DL
><DT
><B
>Table of Contents</B
></DT
><DT
>7.1. <A
HREF="open.html"
>open()</A
></DT
><DT
>7.2. <A
HREF="write.html"
>write()</A
></DT
><DT
>7.3. <A
HREF="read.html"
>read()</A
></DT
><DT
>7.4. <A
HREF="poll.html"
>poll()</A
></DT
><DT
>7.5. <A
HREF="close.html"
>close()</A
></DT
><DT
>7.6. <A
HREF="mmap.html"
>mmap()</A
></DT
><DT
>7.7. <A
HREF="fcntl.html"
>fcntl(sg_fd, F_SETFL, oflags | FASYNC)</A
></DT
><DT
>7.8. <A
HREF="errors.html"
>Errors reported in errno</A
></DT
></DL
></DIV
><P
>System calls that can be used on sg devices are discussed in this chapter.
The ioctl() system call is discussed in the following chapter [ see
<A
HREF="ioctl.html"
>Chapter 8</A
> ].</P
><P
>Successfully opening a sg device file name (e.g. <TT
CLASS="FILENAME"
>/dev/sg0</TT
>) establishes a link between a file descriptor and an attached
SCSI device. The sg driver maintains state information and resources at
both the SCSI device (e.g. exclusive lock) and the file descriptor (e.g.
reserved buffer) levels.</P
><P
>A SCSI device can be detached while an application has a sg file
descriptor open. An example of this is a "hotplug" device such as a USB
mass storage device that has just been unplugged. Most subsequent system
calls that attempt to access the detached SCSI device will yield ENODEV.
The close() call will complete silently while the poll() call will
"or" in POLLHUP to its result. A subsequent attempt to open() that
device name will yield ENODEV.</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="x364.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="open.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>info</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>open()</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>