 
<html><head><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title></title><style type="text/css">
<!--
.style1 {font-size: 18px;font-weight: bold;font-family: Georgia, "Times New Roman", Times, serif;}
.style2 {font-size: 14px}
a{color:#0000cc;text-decoration:none}
a:visited{color:#0000cc;text-decoration:none}
-->
</style></head>
<body style="margin:0px 0px 0px 0px">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#cccccc"><span class="style1" style="margin-left:5px">sys_fchmod <span class="style2">&nbsp;[fs/open.c] </span></span></td>
  </tr>
  <tr>
    <td><p style="margin-left:22px;margin-top:0px"><br />
      Changes S_ISUID, S_ISGID, S_ISVTX, and the file permission bits of a file. It's identical to <a href="015.html">sys_chmod</a> system call except that a file descriptor is used to specify the file. </p>
      <p style="margin-left:10px"><strong>Arguments</strong></p>
      <table width="100%" border="0" style="margin-left:20px; margin-right:20px">
        <tr>
          <td width="6%" valign="top"><em>eax</em></td>
          <td width="94%">94</td>
        </tr>
        <tr>
          <td valign="top"><em>ebx</em></td>
          <td>File descriptor. </td>
        </tr>
        <tr>
          <td valign="top"><em>ecx</em></td>
          <td>Permissions to set:
            <table width="100%" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333">
              <tr>
                <td><code>S_ISUID         &nbsp;- set user ID on execution <br />
S_ISGID         &nbsp;- set group ID on execution <br />
S_ISVTX         &nbsp;- sticky bit<br />
S_IRWXU&nbsp;  -&nbsp;owner has read, write and execute permission <br />
S_IRUSR  &nbsp;-&nbsp;owner has read permission <br />
S_IWUSR&nbsp; -&nbsp;owner has write permission <br />
S_IXUSR&nbsp; -&nbsp;owner has execute permission <br />
S_IRWXG&nbsp; -  group has read, write and execute permission <br />
S_IRGRP&nbsp; -&nbsp;group has read permission <br />
S_IWGRP&nbsp; -  group has write permission <br />
S_IXGRP&nbsp; -  group has execute permission <br />
S_IRWXO  &nbsp;-&nbsp;others have read, write and execute permission <br />
S_IROTH  &nbsp;-&nbsp;others have read permission <br />
S_IWOTH&nbsp; -  others have write permission <br />
S_IXOTH&nbsp;  -  others have execute permission</code></td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      <p style="margin-left:10px" ><strong>Return values</strong></p>
      <p style="margin-left:22px;margin-right:10px" >If the system call succeeds the return value is 0. <br />
      If the system call fails the return value is one of the following  <em>errno</em> values (depending on the file systems other error values may be returned): </p>
      <table width="100%" border="0" style="border:dashed;border-bottom-width:1px;border-left-width:1px;border-right-width:1px;border-top-width:1px;border-color:#333333;margin-left:22px;margin-right:22px">
        <tr>
          <td><table width="100%" border="0">
              <tr>
                <td width="10%" valign="top"><code>-EPERM</code></td>
                <td width="90%"><code>The effective UID does not match the owner of the file, and the process is not   privileged (i.e.: it does not have the CAP_FOWNER capability). </code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EROFS</code></td>
                <td><code>The named file resides on a read-only file system.</code></td>
              </tr>
              <tr>
                <td valign="top"><code>-EBADF </code></td>
                <td><code><em>ebx</em> is not a valid file descriptor. </code></td>
              </tr>

              <tr>
                <td valign="top"><code>-EIO </code></td>
                <td><code>An I/O error occurred while reading from or writing to the file system.</code></td>
              </tr>

          </table></td>
        </tr>
      </table>
      <p style="margin-left:10px"><strong>Remarks</strong></p>
      <p style="margin-left:22px">The effective UID of the calling process must match the owner of the file, or   the process must be privileged (it must have the CAP_FOWNER capability).<br />
        <br />
If the calling process is not privileged (does not have the CAP_FSETID capability), and the group of the file does not match the   effective group ID of the process or one of its supplementary group IDs, the   S_ISGID bit will be turned off, but this will not cause an error to be returned.<br />
<br />
As a security measure, depending on the file system, the set-user-ID and   set-group-ID execution bits may be turned off if a file is written. (this occurs if the writing process does not have the CAP_FSETID capability.) On some file systems, only the superuser can set the sticky bit,   which may have a special meaning. For the sticky bit, and for set-user-ID and   set-group-ID bits on directories, see <a href="106.html">sys_stat</a>.<br />
<br />
On NFS file systems, restricting the permissions will immediately influence   already open files, because the access control is done on the server, but open   files are maintained by the client. Widening the permissions may be delayed for   other clients if attribute caching is enabled on them. </p>
      <p style="margin-left:10px"><strong>Compatibility</strong></p>
    <p style="margin-left:22px">n/a</p></td>
  </tr>
</table></body></html>