📄 posix6.htm
字号:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="GENERATOR" content="Quadralay WebWorks Publisher Professional Edition 6.0.5">
<meta name="TEMPLATEBASE" content="book_html">
<meta name="LASTUPDATED" content="12/04/03 16:07:18">
<title>17.5 POSIX functions</title>
<STYLE TYPE="text/css">
<!--
span.Signal { text-transform: uppercase; font-family: Verdana }
-->
</STYLE>
</head>
<body link="#3366CC" vlink="#9999CC" text="#000000" alink="#0000CC" bgcolor="#FFFFFF"
background="images/backgrnd.gif">
<p><img src="images/stlogo.gif" width="106" height="83" align="left"
alt="logo here!"> </p>
<table width="331" border="0" align="right" cellpadding="0" cellspacing="0">
<tr>
<td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="posix5.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="posix7.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<p><br clear="all">
</p>
<hr align="left">
<blockquote>
<h2>
<a name="1204496"> </a><font color="#003366" face="Verdana, Arial, Helvetica, sans-serif">17.5 POSIX functions</font>
</h2><hr>
<p>
<a name="1204497"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The POSIX functions fall into a number of categories (the first two are provided by virtually all device drivers, the remainder are generally only implemented by file systems):</font>
</p>
<ul>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204498"> </a>basic file operations: <font size=2 face=Courier><strong>open()</strong></font>, <font size=2 face=Courier><strong>close()</strong></font>, <font size=2 face=Courier><strong>read()</strong></font> and <font size=2 face=Courier><strong>write()</strong></font>.</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204499"> </a>device specific operations which are not covered by the generic API, handled through the <font size=2 face=Courier><strong>ioctl()</strong></font> function,</font></p>
<dl>
<dt> <a name="1210425"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">The arguments to this function are interpreted by the device driver in whatever way it sees fit, and can be used to arbitrarily extend the API. For example, setting a baud rate only makes sense to a serial port, not a disk drive.</font>
</dl>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204500"> </a>file name related functions, such as <font size=2 face=Courier><strong>rename()</strong></font> to rename an existing file or directory, <font size=2 face=Courier><strong>remove()</strong></font> which deletes a file, <font size=2 face=Courier><strong>mkdir()</strong></font> and <font size=2 face=Courier><strong>rmdir()</strong></font> which create and delete a directory,</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204501"> </a>status reporting functions, <font size=2 face=Courier><strong>stat()</strong></font> and <font size=2 face=Courier><strong>fstat()</strong></font>, both of which report the same information about a file or directory, but which operate on filename or a file handle respectively,</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204502"> </a>the <font size=2 face=Courier><strong>lseek()</strong></font> function which enables a file read/write pointer to be moved,</font></p>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204503"> </a>the <font size=2 face=Courier><strong>fsync()</strong></font> function which enables buffers to be flushed,</font></p>
<dl>
<dt> <a name="1210429"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">This is required when a device has buffered information before writing it to the final device.</font>
</dl>
<p> <font size=2 face="Verdana, Arial, Helvetica, sans-serif"><li ><a name="1204504"> </a>a set of functions which allow directories to be read in the same way as files: <font size=2 face=Courier><strong>opendir()</strong></font>, <font size=2 face=Courier><strong>readdir()</strong></font> and <font size=2 face=Courier><strong>closedir()</strong></font>.</font></p>
</ul>
<p>
<a name="1204505"> </a><font size=2 face="Verdana, Arial, Helvetica, sans-serif">All of these functions result in calls to the underlying implementation in the device driver. Not all device drivers provide all functions. An attempt to call a function which is not implemented by the device driver will fail, and set <font size=2 face=Courier><strong>errno</strong></font> to <font size=2 face=Courier><strong>ENOENT</strong></font> (in the case of <font size=2 face=Courier><strong>open()</strong></font>) or <font size=2 face=Courier><strong>EBADF</strong></font> (for all other functions).</font>
</p>
</blockquote>
<hr>
<table width="331" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td><a href="a_refman.htm"><img src="images/navtoc.gif" width="84" height="23"
border="0" alt="TOC"> </a></td>
<td><a href="posix5.htm"><img src="images/navprev.gif" width="80" height="23"
border="0" alt="PREV"> </a></td>
<td><a href="posix7.htm"><img src="images/navnext.gif" width="83" height="23"
border="0" alt="NEXT"> </a></td>
<td><a href="a_refmaa.htm"><img src="images/navidx.gif" width="84" height="23"
border="0" alt="INDEX"> </a></td>
</tr>
</table>
<font size=1 face="Verdana, Arial, Helvetica, sans-serif"> © 2001, 2002, 2003 STMicroelectronics. All Rights Reserved.<br>
ADCS 7250966F</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -