Files
oldlinux-files/study/Ref-docs/POSIX/susv3/basedefs/fcntl.h.html
2024-02-19 00:25:23 -05:00

351 lines
11 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta name="generator" content="HTML Tidy, see www.w3.org">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
<title>&lt;fcntl.h&gt;</title>
</head>
<body bgcolor="white">
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
</script>
<basefont size="3"> <a name="&lt;fcntl.h&gt;"></a> <a name="tag_13_11"></a><!-- &lt;fcntl.h&gt; -->
<!--header start-->
<center><font size="2">The Open Group Base Specifications Issue 6<br>
IEEE Std 1003.1-2001<br>
Copyright &copy; 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
<!--header end-->
<hr size="2" noshade>
<h4><a name="tag_13_11_01"></a>NAME</h4>
<blockquote>fcntl.h - file control options</blockquote>
<h4><a name="tag_13_11_02"></a>SYNOPSIS</h4>
<blockquote class="synopsis">
<p><tt>#include &lt;fcntl.h&gt;</tt></p>
</blockquote>
<h4><a name="tag_13_11_03"></a>DESCRIPTION</h4>
<blockquote>
<p>The <i>&lt;fcntl.h&gt;</i> header shall define the following requests and arguments for use by the functions <a href=
"../functions/fcntl.html"><i>fcntl</i>()</a> and <a href="../functions/open.html"><i>open</i>()</a>.</p>
<p>Values for <i>cmd</i> used by <a href="../functions/fcntl.html"><i>fcntl</i>()</a> (the following values are unique) are as
follows:</p>
<dl compact>
<dt>F_DUPFD</dt>
<dd>Duplicate file descriptor.</dd>
<dt>F_GETFD</dt>
<dd>Get file descriptor flags.</dd>
<dt>F_SETFD</dt>
<dd>Set file descriptor flags.</dd>
<dt>F_GETFL</dt>
<dd>Get file status flags and file access modes.</dd>
<dt>F_SETFL</dt>
<dd>Set file status flags.</dd>
<dt>F_GETLK</dt>
<dd>Get record locking information.</dd>
<dt>F_SETLK</dt>
<dd>Set record locking information.</dd>
<dt>F_SETLKW</dt>
<dd>Set record locking information; wait if blocked.</dd>
<dt>F_GETOWN</dt>
<dd>Get process or process group ID to receive SIGURG signals.</dd>
<dt>F_SETOWN</dt>
<dd>Set process or process group ID to receive SIGURG signals.</dd>
</dl>
<p>File descriptor flags used for <a href="../functions/fcntl.html"><i>fcntl</i>()</a> are as follows:</p>
<dl compact>
<dt>FD_CLOEXEC</dt>
<dd>Close the file descriptor upon execution of an <i>exec</i> family function.</dd>
</dl>
<p>Values for <i>l_type</i> used for record locking with <a href="../functions/fcntl.html"><i>fcntl</i>()</a> (the following values
are unique) are as follows:</p>
<dl compact>
<dt>F_RDLCK</dt>
<dd>Shared or read lock.</dd>
<dt>F_UNLCK</dt>
<dd>Unlock.</dd>
<dt>F_WRLCK</dt>
<dd>Exclusive or write lock.</dd>
</dl>
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The values used for <i>l_whence</i>, SEEK_SET, SEEK_CUR, and SEEK_END shall be defined as described in <a href=
"unistd.h.html"><i>&lt;unistd.h&gt;</i></a> . <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p>The following values are file creation flags and are used in the <i>oflag</i> value to <a href=
"../functions/open.html"><i>open</i>()</a>. They shall be bitwise-distinct.</p>
<dl compact>
<dt>O_CREAT</dt>
<dd>Create file if it does not exist.</dd>
<dt>O_EXCL</dt>
<dd>Exclusive use flag.</dd>
<dt>O_NOCTTY</dt>
<dd>Do not assign controlling terminal.</dd>
<dt>O_TRUNC</dt>
<dd>Truncate flag.</dd>
</dl>
<p>File status flags used for <a href="../functions/open.html"><i>open</i>()</a> and <a href=
"../functions/fcntl.html"><i>fcntl</i>()</a> are as follows:</p>
<dl compact>
<dt>O_APPEND</dt>
<dd>Set append mode.</dd>
<dt>O_DSYNC</dt>
<dd><sup>[<a href="javascript:open_code('SIO')">SIO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Write according to synchronized I/O data integrity completion. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt>O_NONBLOCK</dt>
<dd>Non-blocking mode.</dd>
<dt>O_RSYNC</dt>
<dd><sup>[<a href="javascript:open_code('SIO')">SIO</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Synchronized read I/O operations. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd>
<dt>O_SYNC</dt>
<dd>Write according to synchronized I/O file integrity completion.</dd>
</dl>
<p>Mask for use with file access modes is as follows:</p>
<dl compact>
<dt>O_ACCMODE</dt>
<dd>Mask for file access modes.</dd>
</dl>
<p>File access modes used for <a href="../functions/open.html"><i>open</i>()</a> and <a href=
"../functions/fcntl.html"><i>fcntl</i>()</a> are as follows:</p>
<dl compact>
<dt>O_RDONLY</dt>
<dd>Open for reading only.</dd>
<dt>O_RDWR</dt>
<dd>Open for reading and writing.</dd>
<dt>O_WRONLY</dt>
<dd>Open for writing only.</dd>
</dl>
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
The symbolic names for file modes for use as values of <b>mode_t</b> shall be defined as described in <a href=
"sys/stat.h.html"><i>&lt;sys/stat.h&gt;</i></a> . <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
<p><sup>[<a href="javascript:open_code('ADV')">ADV</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Values for <i>advice</i> used by <a href="../functions/posix_fadvise.html"><i>posix_fadvise</i>()</a> are as follows:</p>
<dl compact>
<dt>POSIX_FADV_NORMAL</dt>
<dd><br>
The application has no advice to give on its behavior with respect to the specified data. It is the default characteristic if no
advice is given for an open file.</dd>
<dt>POSIX_FADV_SEQUENTIAL</dt>
<dd><br>
The application expects to access the specified data sequentially from lower offsets to higher offsets.</dd>
<dt>POSIX_FADV_RANDOM</dt>
<dd><br>
The application expects to access the specified data in a random order.</dd>
<dt>POSIX_FADV_WILLNEED</dt>
<dd><br>
The application expects to access the specified data in the near future.</dd>
<dt>POSIX_FADV_DONTNEED</dt>
<dd><br>
The application expects that it will not access the specified data in the near future.</dd>
<dt>POSIX_FADV_NOREUSE</dt>
<dd><br>
The application expects to access the specified data once and then not reuse it thereafter.</dd>
</dl>
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
<p>The structure <b>flock</b> describes a file lock. It shall include the following members:</p>
<pre>
<tt>short l_type </tt> Type of lock; F_RDLCK, F_WRLCK, F_UNLCK. <tt>
short l_whence</tt> Flag for starting offset. <tt>
off_t l_start </tt> Relative offset in bytes. <tt>
off_t l_len </tt> Size; if 0 then until EOF. <tt>
pid_t l_pid </tt> Process ID of the process holding the lock; returned with F_GETLK. <tt>
</tt>
</pre>
<p>The <b>mode_t</b>, <b>off_t</b>, and <b>pid_t</b> types shall be defined as described in <a href=
"sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> .</p>
<p>The following shall be declared as functions and may also be defined as macros. Function prototypes shall be provided.</p>
<pre>
<tt>int creat(const char *, mode_t);
int fcntl(int, int, ...);
int open(const char *, int, ...);
<sup>[<a href="javascript:open_code('ADV')">ADV</a>]</sup><img src="../images/opt-start.gif" alt="[Option Start]" border="0">
int posix_fadvise(int, off_t, size_t, int);
int posix_fallocate(int, off_t, size_t);
<img src="../images/opt-end.gif" alt="[Option End]" border="0">
</tt>
</pre>
<p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
Inclusion of the <i>&lt;fcntl.h&gt;</i> header may also make visible all symbols from <a href=
"../basedefs/sys/stat.h.html"><i>&lt;sys/stat.h&gt;</i></a> and <a href="../basedefs/unistd.h.html"><i>&lt;unistd.h&gt;</i></a>.
<img src="../images/opt-end.gif" alt="[Option End]" border="0"></p>
</blockquote>
<hr>
<div class="box"><em>The following sections are informative.</em></div>
<h4><a name="tag_13_11_04"></a>APPLICATION USAGE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_13_11_05"></a>RATIONALE</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_13_11_06"></a>FUTURE DIRECTIONS</h4>
<blockquote>
<p>None.</p>
</blockquote>
<h4><a name="tag_13_11_07"></a>SEE ALSO</h4>
<blockquote>
<p><a href="sys/stat.h.html"><i>&lt;sys/stat.h&gt;</i></a> , <a href="sys/types.h.html"><i>&lt;sys/types.h&gt;</i></a> , <a href=
"unistd.h.html"><i>&lt;unistd.h&gt;</i></a> , the System Interfaces volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href=
"../functions/creat.html"><i>creat</i>()</a>, <i>exec</i>, <a href="../functions/fcntl.html"><i>fcntl</i>()</a>, <a href=
"../functions/open.html"><i>open</i>()</a>, <a href="../functions/posix_fadvise.html"><i>posix_fadvise</i>()</a>, <a href=
"../functions/posix_fallocate.html"><i>posix_fallocate</i>()</a>, <a href=
"../functions/posix_madvise.html"><i>posix_madvise</i>()</a></p>
</blockquote>
<h4><a name="tag_13_11_08"></a>CHANGE HISTORY</h4>
<blockquote>
<p>First released in Issue 1. Derived from Issue 1 of the SVID.</p>
</blockquote>
<h4><a name="tag_13_11_09"></a>Issue 5</h4>
<blockquote>
<p>The DESCRIPTION is updated for alignment with the POSIX Realtime Extension.</p>
</blockquote>
<h4><a name="tag_13_11_10"></a>Issue 6</h4>
<blockquote>
<p>The following changes are made for alignment with the ISO&nbsp;POSIX-1:1996 standard:</p>
<ul>
<li>
<p>O_DSYNC and O_RSYNC are marked as part of the Synchronized Input and Output option.</p>
</li>
</ul>
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
<ul>
<li>
<p>The definition of the <b>mode_t</b>, <b>off_t</b>, and <b>pid_t</b> types is mandated.</p>
</li>
</ul>
<p>The F_GETOWN and F_SETOWN values are added for sockets.</p>
<p>The <a href="../functions/posix_fadvise.html"><i>posix_fadvise</i>()</a>, <a href=
"../functions/posix_fallocate.html"><i>posix_fallocate</i>()</a>, and <a href=
"../functions/posix_madvise.html"><i>posix_madvise</i>()</a> functions are added for alignment with
IEEE&nbsp;Std&nbsp;1003.1d-1999.</p>
<p>IEEE PASC Interpretation 1003.1 #102 is applied, moving the prototype for <a href=
"../functions/posix_madvise.html"><i>posix_madvise</i>()</a> to <a href=
"../basedefs/sys/mman.h.html"><i>&lt;sys/mman.h&gt;</i></a>.</p>
</blockquote>
<div class="box"><em>End of informative text.</em></div>
<hr>
<hr size="2" noshade>
<center><font size="2"><!--footer start-->
UNIX &reg; is a registered Trademark of The Open Group.<br>
POSIX &reg; is a registered Trademark of The IEEE.<br>
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
]</font></center>
<!--footer end-->
<hr size="2" noshade>
</body>
</html>