⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fchmod.html

📁 IEEE 1003.1-2003, Single Unix Specification v3
💻 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-2003 The Open Group, All Rights Reserved --><title>fchmod</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="fchmod"></a> <a name="tag_03_138"></a><!-- fchmod --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright &copy; 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_138_01"></a>NAME</h4><blockquote>fchmod - change mode of a file</blockquote><h4><a name="tag_03_138_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/sys/stat.h.html">sys/stat.h</a>&gt;<br><br> int fchmod(int</tt> <i>fildes</i><tt>, mode_t</tt> <i>mode</i><tt>);<br></tt></code></p></blockquote><h4><a name="tag_03_138_03"></a>DESCRIPTION</h4><blockquote><p>The <i>fchmod</i>() function shall be equivalent to <a href="../functions/chmod.html"><i>chmod</i>()</a> except that the filewhose permissions are changed is specified by the file descriptor <i>fildes</i>.</p><p><sup>[<a href="javascript:open_code('SHM')">SHM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If <i>fildes</i> references a shared memory object, the <i>fchmod</i>() function need only affect the S_IRUSR, S_IWUSR, S_IRGRP,S_IWGRP, S_IROTH, and S_IWOTH file permission bits. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p><sup>[<a href="javascript:open_code('TYM')">TYM</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If <i>fildes</i> references a typed memory object, the behavior of <i>fchmod</i>() is unspecified. <img src="../images/opt-end.gif"alt="[Option End]" border="0"></p><p>If <i>fildes</i> refers to a socket, the behavior of <i>fchmod</i>() is unspecified.</p><p><sup>[<a href="javascript:open_code('XSR')">XSR</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">If <i>fildes</i> refers to a STREAM (which is <a href="../functions/fattach.html"><i>fattach</i>()</a>-ed into the file system namespace) the call returns successfully, doing nothing. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_138_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, <i>fchmod</i>() shall return 0. Otherwise, it shall return -1 and set <i>errno</i> to indicate theerror.</p></blockquote><h4><a name="tag_03_138_05"></a>ERRORS</h4><blockquote><p>The <i>fchmod</i>() function shall fail if:</p><dl compact><dt>[EBADF]</dt><dd>The <i>fildes</i> argument is not an open file descriptor.</dd><dt>[EPERM]</dt><dd>The effective user ID does not match the owner of the file and the process does not have appropriate privilege.</dd><dt>[EROFS]</dt><dd>The file referred to by <i>fildes</i> resides on a read-only file system.</dd></dl><p>The <i>fchmod</i>() function may fail if:</p><dl compact><dt>[EINTR]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The <i>fchmod</i>() function was interrupted by a signal. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The value of the <i>mode</i> argument is invalid. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EINVAL]</dt><dd>The <i>fildes</i> argument refers to a pipe and the implementation disallows execution of <i>fchmod</i>() on a pipe.</dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_138_06"></a>EXAMPLES</h4><blockquote><h5><a name="tag_03_138_06_01"></a>Changing the Current Permissions for a File</h5><p>The following example shows how to change the permissions for a file named <b>/home/cnd/mod1</b> so that the owner and grouphave read/write/execute permissions, but the world only has read/write permissions.</p><pre><tt>#include &lt;sys/stat.h&gt;#include &lt;fcntl.h&gt;<br>mode_t mode;int    fildes;...fildes = open("/home/cnd/mod1", O_RDWR);fchmod(fildes, S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH);</tt></pre></blockquote><h4><a name="tag_03_138_07"></a>APPLICATION USAGE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_138_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_138_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_138_10"></a>SEE ALSO</h4><blockquote><p><a href="chmod.html"><i>chmod</i>()</a> , <a href="chown.html"><i>chown</i>()</a> , <a href="creat.html"><i>creat</i>()</a> , <ahref="fcntl.html"><i>fcntl</i>()</a> , <a href="fstatvfs.html"><i>fstatvfs</i>()</a> , <a href="mknod.html"><i>mknod</i>()</a> , <ahref="open.html"><i>open</i>()</a> , <a href="read.html"><i>read</i>()</a> , <a href="stat.html"><i>stat</i>()</a> , <a href="write.html"><i>write</i>()</a> , the Base Definitions volume of IEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/sys/stat.h.html"><i>&lt;sys/stat.h&gt;</i></a></p></blockquote><h4><a name="tag_03_138_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 4, Version 2.</p></blockquote><h4><a name="tag_03_138_12"></a>Issue 5</h4><blockquote><p>Moved from X/OPEN UNIX extension to BASE and aligned with <i>fchmod</i>() in the POSIX Realtime Extension. Specifically, thesecond paragraph of the DESCRIPTION is added and a second instance of [EINVAL] is defined in the list of optional errors.</p></blockquote><h4><a name="tag_03_138_13"></a>Issue 6</h4><blockquote><p>The DESCRIPTION is updated for alignment with IEEE&nbsp;Std&nbsp;1003.1j-2000 by stating that <i>fchmod</i>() behavior isunspecified for typed memory objects.</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -