1030 lines
24 KiB
HTML
1030 lines
24 KiB
HTML
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
|
||
|
<title>chmod()--Change File Authorizations</title>
|
||
|
<!-- Begin Header Records ========================================== -->
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<!-- Change History: -->
|
||
|
<!-- YYMMDD USERID Change description -->
|
||
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
||
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
||
|
<!-- 010314 JTROUS Modify S_ISGID description, V5R2, 98686 -->
|
||
|
<!-- 010320 JTROUS Include Journal ERRNOs, should have in V5R1 -->
|
||
|
<!-- and changed example to check errno on each IFS -->
|
||
|
<!-- call, but did not change flag these latter chgs -->
|
||
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
||
|
<!-- 020131 JTROUS Changes from API Review 3, V5R2 -->
|
||
|
<!-- 020618 EMIG Updates for NFS threadsafety, V5R3 -->
|
||
|
<!-- 020715 Rosckes Add table to include special save file case -->
|
||
|
<!-- 020514 JET This file has undergone html cleanup -->
|
||
|
<!-- 020718 MFENLON: updated for QFileSvr.400 threadsafety, V5R3 -->
|
||
|
<!-- 020829 RTHEIS : S_ISVTX mode bit, V5R3 -->
|
||
|
<!-- 050321 JTROUS: fix enums, no change flag, V5R4 -->
|
||
|
<!-- End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!--Java sync-link-->
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>chmod()--Change File Authorizations</h2>
|
||
|
|
||
|
<div class="box" style="width: 70%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/stat.h>
|
||
|
|
||
|
int chmod(const char <em>*path</em>, mode_t <em>mode</em>);
|
||
|
</pre>
|
||
|
|
||
|
Service Program Name: QP0LLIB1<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Conditional; see <a href="#HDRCHMODUS">Usage
|
||
|
Notes</a>.<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
|
||
|
<p>The <strong>chmod()</strong> function changes S_ISUID, S_ISGID,
|
||
|
S_ISVTX,
|
||
|
and the
|
||
|
permission bits of the file or directory specified in <em>path</em> to the
|
||
|
corresponding bits specified in <em>mode</em>. If the named file is a symbolic
|
||
|
link, <strong>chmod()</strong> resolves the symbolic link. <strong>
|
||
|
chmod()</strong> has no effect on file descriptions for files that are open at
|
||
|
the time <strong>chmod()</strong> is called.</p>
|
||
|
|
||
|
<p>When <strong>chmod()</strong> is successful it updates the change time of
|
||
|
the file.</p>
|
||
|
|
||
|
<p>If the file is checked out by another user (someone other than the user
|
||
|
profile of the current job), <strong>chmod()</strong> fails with the [EBUSY]
|
||
|
error.</p>
|
||
|
|
||
|
<br>
|
||
|
<h3>Parameters</h3>
|
||
|
|
||
|
<dl>
|
||
|
<dt><strong><em>path</em></strong></dt>
|
||
|
|
||
|
<dd>(Input) A pointer to the null-terminated path name of the file whose mode
|
||
|
is being changed.
|
||
|
|
||
|
<p>This parameter is assumed to be represented in the CCSID (coded character
|
||
|
set identifier) currently in effect for the job. If the CCSID of the job is
|
||
|
65535, this parameter is assumed to be represented in the default CCSID of the
|
||
|
job.</p>
|
||
|
|
||
|
<p>See <a href="chmodu.htm">QlgChmod()--Change File Authorizations</a> for a
|
||
|
description and an example of supplying the <em>path</em> in any CCSID.</p>
|
||
|
|
||
|
<br>
|
||
|
</dd>
|
||
|
|
||
|
<dt><strong><em>mode</em></strong></dt>
|
||
|
|
||
|
<dd>(Input) Bits that define S_ISUID, S_ISGID,
|
||
|
S_ISVTX,
|
||
|
and the access permissions of
|
||
|
the file.
|
||
|
|
||
|
<p>The <em>mode</em> argument is created with one of the following symbols
|
||
|
defined in the <<strong>sys/stat.h</strong>> include file.
|
||
|
|
||
|
See the <a href="#HDRCHMODUS">Usage Notes</a> for the file system differences
|
||
|
regarding these symbols.
|
||
|
|
||
|
</p>
|
||
|
|
||
|
<dl compact>
|
||
|
<dt><em>S_IRUSR</em></dt>
|
||
|
|
||
|
<dd>Read permission for the file owner</dd>
|
||
|
|
||
|
<dt><em>S_IWUSR</em></dt>
|
||
|
|
||
|
<dd>Write permission for the file owner</dd>
|
||
|
|
||
|
<dt><em>S_IXUSR</em></dt>
|
||
|
|
||
|
<dd>Search permission (for a directory) or execute permission (for a file) for
|
||
|
the file owner</dd>
|
||
|
|
||
|
<dt><em>S_IRWXU</em></dt>
|
||
|
|
||
|
<dd>Read, write, and search or execute for the file owner. S_IRWXU is the
|
||
|
bitwise inclusive OR of S_IRUSR, S_IWUSR, and S_IXUSR</dd>
|
||
|
|
||
|
<dt><em>S_IRGRP</em></dt>
|
||
|
|
||
|
<dd>Read permission for the file's group</dd>
|
||
|
|
||
|
<dt><em>S_IWGRP</em></dt>
|
||
|
|
||
|
<dd>Write permission for the file's group</dd>
|
||
|
|
||
|
<dt><em>S_IXGRP</em></dt>
|
||
|
|
||
|
<dd>Search permission (for a directory) or execute permission (for a file) for
|
||
|
the file's group</dd>
|
||
|
|
||
|
<dt><em>S_IRWXG</em></dt>
|
||
|
|
||
|
<dd>Read, write, and search or execute permission for the file's group. S_IRWXG
|
||
|
is the bitwise inclusive OR of S_IRGRP, S_IWGRP, and S_IXGRP</dd>
|
||
|
|
||
|
<dt><em>S_IROTH</em></dt>
|
||
|
|
||
|
<dd>General read permission</dd>
|
||
|
|
||
|
<dt><em>S_IWOTH</em></dt>
|
||
|
|
||
|
<dd>General write permission</dd>
|
||
|
|
||
|
<dt><em>S_IXOTH</em></dt>
|
||
|
|
||
|
<dd>General search permission (for a directory) or general execute permission
|
||
|
(for a file)</dd>
|
||
|
|
||
|
<dt><em>S_IRWXO</em></dt>
|
||
|
|
||
|
<dd>General read, write, and search or execute permission. S_IRWXO is the
|
||
|
bitwise inclusive OR of S_IROTH, S_IWOTH, and S_IXOTH</dd>
|
||
|
|
||
|
<dt><em>S_ISUID</em></dt>
|
||
|
|
||
|
<dd>Set effective user ID at execution time. This bit is ignored if the object
|
||
|
specified by <em>path</em> is a directory.</dd>
|
||
|
|
||
|
<dt><em>S_ISGID</em></dt>
|
||
|
|
||
|
<dd>Set effective group ID at execution time. See <a href="#HDRCHMODUS">Usage
|
||
|
Notes</a> for more information if the object specified by <em>path</em> is a
|
||
|
directory.</dd>
|
||
|
|
||
|
|
||
|
<dt><em>S_ISVTX</em></dt>
|
||
|
|
||
|
<dd>Restricted renames and unlinks for objects within a directory. Objects can be linked into
|
||
|
a directory that has this bit set on, but cannot be renamed or unlinked from it
|
||
|
unless one or more of the following are true for the user performing the operation:
|
||
|
<ul><li>The user is the owner of the object.</li>
|
||
|
<li>The user is the owner of the directory.</li>
|
||
|
<li>The user has all object (*ALLOBJ) special authority.</li>
|
||
|
</ul>
|
||
|
This restriction only applies to directories in the "root" (/), QOpenSys, and user-defined
|
||
|
file systems. Other types of object and directories in other file systems may have
|
||
|
this bit on, however, it will be ignored.</dd>
|
||
|
|
||
|
|
||
|
</dl>
|
||
|
|
||
|
<p>If bits other than the bits listed above are set in <em>mode</em>, <strong>
|
||
|
chmod()</strong> returns the [EINVAL] error.</p>
|
||
|
</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Authorities</h3>
|
||
|
|
||
|
<p><strong>Note:</strong> Adopted authority is not used.</p>
|
||
|
|
||
|
<strong><a name="TBLACHMOD">Authorization required for chmod() (excluding
|
||
|
QDLS, QSYS.LIB, and Independent ASP QSYS.LIB)</a></strong><br>
|
||
|
|
||
|
<table border cellpadding="5" width="80%">
|
||
|
<tr>
|
||
|
<th align="left" valign="bottom">Object Referred to</th>
|
||
|
<th align="left" valign="bottom">Authority Required</th>
|
||
|
<th align="left" valign="bottom">errno</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Each directory in the path name preceding the
|
||
|
object</td>
|
||
|
<td align="center" valign="top">*X</td>
|
||
|
<td align="left" valign="top">EACCES</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Object</td>
|
||
|
<td align="center" valign="top">Owner (see <strong>Note</strong>)</td>
|
||
|
<td align="left" valign="top">EPERM</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top" colspan="3"><strong>Note:</strong> You do not
|
||
|
need the listed authority if you have *ALLOBJ special authority.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
<strong><a name="TBLACHMOD3">Authorization required for chmod() in the QDLS
|
||
|
File System</a></strong><br>
|
||
|
<table border cellpadding="5" width="80%">
|
||
|
<tr>
|
||
|
<th align="left" valign="bottom">Object Referred to</th>
|
||
|
<th align="left" valign="bottom">Authority Required</th>
|
||
|
<th align="left" valign="bottom">errno</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Each directory in the path name preceding the
|
||
|
object</td>
|
||
|
<td align="center" valign="top">*X</td>
|
||
|
<td align="left" valign="top">EACCES</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Object</td>
|
||
|
<td align="center" valign="top">Owner or *ALL</td>
|
||
|
<td align="left" valign="top">EACCES</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
|
||
|
<strong><a name="TBLACHMOD2">Authorization required for chmod() in the QSYS.LIB and Independent ASP QSYS.LIB
|
||
|
file systems.
|
||
|
</a></strong><br>
|
||
|
<table border cellpadding="5" width="80%">
|
||
|
<tr>
|
||
|
<th align="left" valign="bottom">Object Referred to</th>
|
||
|
<th align="left" valign="bottom">Authority Required</th>
|
||
|
<th align="left" valign="bottom">errno</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Each directory in the path name preceding the
|
||
|
object</td>
|
||
|
<td align="center" valign="top">*X</td>
|
||
|
<td align="left" valign="top">EACCES</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">The parent directory of the
|
||
|
object if the object is a save file</td>
|
||
|
<td align="center" valign="top">*RX</td>
|
||
|
<td align="left" valign="top">EPERM</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">Object</td>
|
||
|
<td align="center" valign="top">Owner (see <strong>Note</strong>)</td>
|
||
|
<td align="left" valign="top">EPERM</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top" colspan="3"><strong>Note:</strong> You do not
|
||
|
need the listed authority if you have *ALLOBJ special authority.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
<h3>Return Value</h3>
|
||
|
|
||
|
<dl compact>
|
||
|
<dt><em>0</em></dt>
|
||
|
|
||
|
<dd><strong>chmod()</strong> was successful.</dd>
|
||
|
|
||
|
<dt><em>-1</em></dt>
|
||
|
|
||
|
<dd><strong>chmod()</strong> was not successful. The <em>errno</em> global
|
||
|
variable is set to indicate the error.</dd>
|
||
|
</dl>
|
||
|
|
||
|
<br>
|
||
|
<h3>Error Conditions</h3>
|
||
|
|
||
|
<p>If <strong>chmod()</strong> is not successful, <em>errno</em> usually
|
||
|
indicates one of the following errors. Under some conditions, <em>errno</em>
|
||
|
could indicate an error other than those listed here.</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="25 75" -->
|
||
|
|
||
|
<tr>
|
||
|
<th align="left" valign="bottom">Error condition</th>
|
||
|
<th align="left" valign="bottom">Additional information</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EACCES">EACCES</a>]</em></td>
|
||
|
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
<p>If you are accessing a remote file through the Network File System, update
|
||
|
operations to file permissions at the server are not reflected at the client
|
||
|
until updates to data that is stored locally by the Network File System take
|
||
|
place. (Several options on the Add Mounted File System (ADDMFS) command
|
||
|
determine the time between refresh operations of local data.) Access to a
|
||
|
remote file may also fail due to different mappings of user IDs (UID) or group
|
||
|
IDs (GID) on the local and remote systems.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EAGAIN">EAGAIN</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EBADFID">EBADFID</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EBADNAME">EBADNAME</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EBUSY">EBUSY</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ECONVERT">ECONVERT</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EDAMAGE">EDAMAGE</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EFAULT">EFAULT</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EFILECVT">EFILECVT</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EINTR">EINTR</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EINVAL">EINVAL</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EIO">EIO</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EJRNDAMAGE">EJRNDAMAGE</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EJRNENTTOOLONG">EJRNENTTOOLONG</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EJRNINACTIVE">EJRNINACTIVE</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EJRNRCVSPC">EJRNRCVSPC</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ELOOP">ELOOP</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENAMETOOLONG">ENAMETOOLONG</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENEWJRN">ENEWJRN</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENEWJRNRCV">ENEWJRNRCV</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENOENT">ENOENT</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENOSPC">ENOSPC</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENOTAVAIL">ENOTAVAIL</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENOTDIR">ENOTDIR</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENOTSAFE">ENOTSAFE</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENOTSUP">ENOTSUP</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EPERM">EPERM</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EROOBJ">EROOBJ</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ESTALE">ESTALE</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
<p>If you are accessing a remote file through the Network File System, the file
|
||
|
may have been deleted at the server.</p>
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EUNKNOWN">EUNKNOWN</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>If interaction with a file server is required to access the object, <em>
|
||
|
errno</em> could also indicate one of the following errors:</p>
|
||
|
|
||
|
<table cellpadding="5">
|
||
|
<!-- cols="25 75" -->
|
||
|
|
||
|
<tr>
|
||
|
<th align="left" valign="bottom">Error condition</th>
|
||
|
<th align="left" valign="bottom">Additional information</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EADDRNOTAVAIL">EADDRNOTAVAIL</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ECONNABORTED">ECONNABORTED</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ECONNREFUSED">ECONNREFUSED</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ECONNRESET">ECONNRESET</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EHOSTDOWN">EHOSTDOWN</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EHOSTUNREACH">EHOSTUNREACH</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENETDOWN">ENETDOWN</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENETRESET">ENETRESET</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ENETUNREACH">ENETUNREACH</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#ETIMEDOUT">ETIMEDOUT</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td align="left" valign="top">
|
||
|
<em>[<a href="unix14.htm#EUNATCH">EUNATCH</a>]</em></td>
|
||
|
|
||
|
<td align="left" valign="top">
|
||
|
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
<h3>Error Messages</h3>
|
||
|
|
||
|
<p>The following messages may be sent from this function:</p>
|
||
|
|
||
|
<table width="100%">
|
||
|
<tr>
|
||
|
<th align="left" valign="top">Message ID</th>
|
||
|
<th align="left" valign="top">Error Message Text</th>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td width="15%" valign="top">CPE3418 E</td>
|
||
|
<td width="85%" valign="top">Possible APAR condition or hardware failure.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top">CPFA0D4 E</td>
|
||
|
<td valign="top">File system error occurred. Error number &1.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top">CPF3CF2 E</td>
|
||
|
<td valign="top">Error(s) occurred during running of &1 API.</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td valign="top">CPF9872 E</td>
|
||
|
<td valign="top">Program or service program &1 in library &2 ended.
|
||
|
Reason code &3.</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<br>
|
||
|
<br>
|
||
|
<h3><a name="HDRCHMODUS">Usage Notes</a></h3>
|
||
|
|
||
|
<ol type="1">
|
||
|
<li>This function will fail with error code [ENOTSAFE] when all the following
|
||
|
conditions are true:<br>
|
||
|
<br>
|
||
|
|
||
|
|
||
|
<ul>
|
||
|
<li>Where multiple threads exist in the job.<br>
|
||
|
</li>
|
||
|
|
||
|
<li>The object on which this function is operating resides in a file system
|
||
|
that is not threadsafe. Only the following file systems are threadsafe for this
|
||
|
function:<br>
|
||
|
<br>
|
||
|
<ul>
|
||
|
<li>"Root" (/)</li>
|
||
|
|
||
|
<li>QOpenSys</li>
|
||
|
|
||
|
<li>User-defined</li>
|
||
|
|
||
|
<li>QNTC</li>
|
||
|
|
||
|
<li>QSYS.LIB</li>
|
||
|
|
||
|
<li>Independent ASP QSYS.LIB</li>
|
||
|
|
||
|
<li>QOPT</li>
|
||
|
|
||
|
<li>Network File System</li>
|
||
|
|
||
|
|
||
|
<li>QFileSvr.400</li>
|
||
|
|
||
|
</ul>
|
||
|
</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>"Root" (/), QOpenSys, and User-Defined File System Differences
|
||
|
|
||
|
<p>If the object has a primary group, it must match the primary group ID or one
|
||
|
of the supplemental group IDs of the caller of the API; otherwise, the S_ISGID
|
||
|
bit is turned off.</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>QSYS.LIB and independent ASP QSYS.LIB File System Differences
|
||
|
|
||
|
<p><strong>chmod()</strong> is not supported for member (.MBR) objects.</p>
|
||
|
|
||
|
<p><strong>chmod()</strong> returns EBUSY if the object is allocated in
|
||
|
another job.</p>
|
||
|
|
||
|
<p>QSYS.LIB and independent ASP QSYS.LIB do not support setting the S_ISUID
|
||
|
(set-user-ID), S_ISGID (set-group_ID), and
|
||
|
S_ISVTX (restricted rename and unlink)
|
||
|
bits. If they are turned on in the
|
||
|
mode parameter, they are ignored.</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>QDLS File System Differences
|
||
|
|
||
|
<p>Changing the permissions of the /QDLS directory (the root folder) is not
|
||
|
allowed. If an attempt is made to change the permissions, error ENOTSUP is
|
||
|
returned.</p>
|
||
|
|
||
|
<p>"Group" rights are not set if there is no current group.</p>
|
||
|
|
||
|
<p> QDLS does not support setting the S_ISUID, S_ISGID, and
|
||
|
S_ISVTX
|
||
|
bits. If they are
|
||
|
turned on in the mode parameter, they are ignored.</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>QOPT File System Differences
|
||
|
|
||
|
<p>Changing the permissions is allowed only for an object that exists on a
|
||
|
volume formatted in Universal Disk Format (UDF). For all other media formats,
|
||
|
ENOTSUP is returned.</p>
|
||
|
|
||
|
<p>In addition to the authorization checks described in <a href="#TBLACHMOD">
|
||
|
Authorization Required for chmod()</a>, the volume authorization list is
|
||
|
checked for *CHANGE authority.</p>
|
||
|
|
||
|
<p>QOPT does not support setting the S_ISUID, S_ISGID, and
|
||
|
S_ISVTX
|
||
|
bits for any optical
|
||
|
media format. If they are turned on in the mode parameter, ENOTSUP is
|
||
|
returned.</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>QNetWare File System Differences
|
||
|
|
||
|
<p>The QNetWare file system does not fully support <strong>chmod()</strong>.
|
||
|
See <a href="../rzaef/rzaefoverview.htm">NetWare on iSeries</a> for more
|
||
|
information.</p>
|
||
|
|
||
|
<p>QNetWare supports the S_ISUID and S_ISGID
|
||
|
bits by passing them to the server
|
||
|
and surfacing them to the caller. Some versions of NetWare may support the bits
|
||
|
and others may not.</p>
|
||
|
|
||
|
|
||
|
<p>QNetWare does not support setting the S_ISVTX bit. If it is turned on in the
|
||
|
mode parameter, ENOTSUP is returned.
|
||
|
</p>
|
||
|
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>QFileSvr.400 Differences
|
||
|
|
||
|
<p>QFileSvr.400 supports the S_ISUID, S_ISGID, and
|
||
|
S_ISVTX
|
||
|
bits by passing them to the
|
||
|
server and surfacing them to the caller.</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>Network File System Differences
|
||
|
|
||
|
<p>The NFS client supports the S_ISUID, S_ISGID, and
|
||
|
S_ISVTX
|
||
|
bits by passing them to the
|
||
|
server over the network and surfacing them to the caller. Whether a particular
|
||
|
network file system supports the setting of these bits depends on the server.
|
||
|
Most servers have the capability of masking off the
|
||
|
S_ISUID and S_ISGID
|
||
|
bits if the NOSUID option
|
||
|
is specified on the export. The default, however, is to support these
|
||
|
two
|
||
|
bits.
|
||
|
</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>QNTC File System Differences
|
||
|
|
||
|
<p><strong>chmod()</strong> does not update the Windows NT server access
|
||
|
control lists that control the authority of users to the file or directory. The
|
||
|
mode settings are ignored.</p>
|
||
|
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li>S_ISGID bit of a directory in "root" (/), QOpenSys, or User-Defined File System
|
||
|
|
||
|
<p>The S_ISGID bit of the directory affects what the group ID (GID) is for
|
||
|
objects that are created in the directory. If the S_ISGID bit of the parent
|
||
|
directory is off, the group ID (GID) is set to the effective GID of the thread
|
||
|
creating the object. If the S_ISGID bit of the parent directory is on, the
|
||
|
group ID (GID) of the new object is set to the GID of the parent directory. For
|
||
|
all other file systems, the GID of the new object is set to the GID of the
|
||
|
parent directory.</p>
|
||
|
</li>
|
||
|
|
||
|
</ol>
|
||
|
|
||
|
<br>
|
||
|
<h3>Related Information</h3>
|
||
|
|
||
|
<ul>
|
||
|
<li>The <<strong>sys/types.h</strong>> file (see <a href="unix13.htm">
|
||
|
Header Files for UNIX-Type Functions</a>)
|
||
|
</li>
|
||
|
|
||
|
<li>The <<strong>sys/stat.h</strong>> file (see <a href="unix13.htm">
|
||
|
Header Files for UNIX-Type Functions</a>)
|
||
|
</li>
|
||
|
|
||
|
<li><a href="chown.htm">chown()</a>--Change Owner and Group of File
|
||
|
</li>
|
||
|
|
||
|
<li><a href="fchmod.htm">fchmod()</a>--Change File Authorizations by
|
||
|
Descriptor
|
||
|
</li>
|
||
|
|
||
|
<li><a href="mkdir.htm">mkdir()</a>--Make Directory
|
||
|
</li>
|
||
|
|
||
|
<li><a href="open.htm">open()</a>--Open File
|
||
|
</li>
|
||
|
|
||
|
<li><a href="stat.htm">stat()</a>--Get File Information
|
||
|
</li>
|
||
|
|
||
|
<li><a href="chmodu.htm">QlgChmod()</a>--Change File Authorizations</li>
|
||
|
</ul>
|
||
|
|
||
|
<br>
|
||
|
<h3>Example</h3>
|
||
|
|
||
|
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
|
||
|
for information pertaining to code examples.</p>
|
||
|
|
||
|
<p>The following example changes the permissions for a file:</p>
|
||
|
|
||
|
<pre>
|
||
|
#include <stdio.h>
|
||
|
#include <sys/stat.h>
|
||
|
#include <sys/types.h>
|
||
|
|
||
|
main() {
|
||
|
char fn[]="temp.file";
|
||
|
int file_descriptor;
|
||
|
struct stat info;
|
||
|
|
||
|
if ((file_descriptor = creat(fn, S_IWUSR)) == -1)
|
||
|
perror("creat() error");
|
||
|
else {
|
||
|
if (stat(fn, &info)!= 0)
|
||
|
perror("stat() error");
|
||
|
else {
|
||
|
printf("original permissions were: %08o\n", info.st_mode);
|
||
|
}
|
||
|
if (chmod(fn, S_IRWXU|S_IRWXG) != 0)
|
||
|
perror("chmod() error");
|
||
|
else {
|
||
|
if (stat(fn, &info)!= 0)
|
||
|
perror("stat() error");
|
||
|
else {
|
||
|
printf("after chmod(), permissions are: %08o\n", info.st_mode);
|
||
|
}
|
||
|
}
|
||
|
if (close(file_descriptor)!= 0)
|
||
|
perror("close() error");
|
||
|
if (unlink(fn)!= 0)
|
||
|
perror("unlink() error");
|
||
|
}
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>Output:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
original permissions were: 00100200
|
||
|
after chmod(), permissions are: 00100770
|
||
|
</pre>
|
||
|
|
||
|
<br>
|
||
|
<hr>
|
||
|
API introduced: V3R1
|
||
|
|
||
|
<hr>
|
||
|
<center>
|
||
|
<table cellpadding="2" cellspacing="2">
|
||
|
<tr align="center">
|
||
|
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
|
||
|
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</center>
|
||
|
</body>
|
||
|
</html>
|
||
|
|