38 lines
1.3 KiB
HTML
38 lines
1.3 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
|
|
<TITLE>The Linux SCSI programming HOWTO: Opening The Device</TITLE>
|
|
<LINK HREF="SCSI-Programming-HOWTO-8.html" REL=next>
|
|
<LINK HREF="SCSI-Programming-HOWTO-6.html" REL=previous>
|
|
<LINK HREF="SCSI-Programming-HOWTO.html#toc7" REL=contents>
|
|
</HEAD>
|
|
<BODY>
|
|
<A HREF="SCSI-Programming-HOWTO-8.html">Next</A>
|
|
<A HREF="SCSI-Programming-HOWTO-6.html">Previous</A>
|
|
<A HREF="SCSI-Programming-HOWTO.html#toc7">Contents</A>
|
|
<HR>
|
|
<H2><A NAME="s7">7. Opening The Device</A></H2>
|
|
|
|
<P>A generic device has to be opened for read and write access:
|
|
<P>
|
|
<BLOCKQUOTE><CODE>
|
|
<PRE>
|
|
int fd = open (device_name, O_RDWR);
|
|
</PRE>
|
|
</CODE></BLOCKQUOTE>
|
|
<P>(This is the case even for a read-only hardware device such as a cdrom
|
|
drive).
|
|
<P>We have to perform a <CODE>write</CODE> to send the command and a <CODE>read</CODE>
|
|
to get back any results. In the case of an error the return code is
|
|
negative (see section
|
|
<A HREF="SCSI-Programming-HOWTO-21.html#sec-errorhandling">sec-errorhandling</A>
|
|
for a complete list).
|
|
<P>
|
|
<HR>
|
|
<A HREF="SCSI-Programming-HOWTO-8.html">Next</A>
|
|
<A HREF="SCSI-Programming-HOWTO-6.html">Previous</A>
|
|
<A HREF="SCSI-Programming-HOWTO.html#toc7">Contents</A>
|
|
</BODY>
|
|
</HTML>
|