Changes file access permissions.
Standard C Library (libc.a)
int chmod ( Path, Mode)
const char *Path;
int fchmod ( FileDescriptor, Mode)
The chmod subroutine sets the access permissions of the file specified by the Path parameter. If Network File System (NFS) is installed on your system, this path can cross into another node.
Use the fchmod subroutine to set the access permissions of an open file pointed to by the FileDescriptor parameter.
The access control information is set according to the Mode parameter.
|FileDescriptor||Specifies the file descriptor of an open file.|
|Mode||Specifies the bit pattern that determines the access permissions.
The Mode parameter is constructed by logically ORing one or more of
the following values, which are defined in the sys/mode.h file:
The following attributes apply only to files that are directly executable. They have no meaning when applied to executable text files such as shell scripts and awk scripts.
Other mode values exist that can be set with the mknod subroutine but not with the chmod subroutine.
|Path||Specifies the full path name of the file.|
Upon successful completion, the chmod subroutine and fchmod subroutines return a value of 0. If the chmod subroutine or fchmod subroutine is unsuccessful, a value of -1 is returned, and the errno global variable is set to identify the error.
The chmod subroutine is
unsuccessful and the file permissions remain unchanged if one of the following
|ENOTDIR||A component of the Path prefix is not a directory.|
|EACCES||Search permission is denied on a component of the Path prefix.|
|EFAULT||The Path parameter points to a location outside of the allocated address space of the process.|
|ELOOP||Too many symbolic links were encountered in translating the Path parameter.|
|ENOENT||The named file does not exist.|
|ENAMETOOLONG||A component of the Path parameter exceeded 255 characters, or the entire Path parameter exceeded 1023 characters.|
The fchmod subroutine is unsuccessful and the file permissions
remain unchanged if the following is true:
|EBADF||The value of the FileDescriptor parameter is not valid.|
The chmod or fchmod subroutine is unsuccessful and
the access control information for a file remains unchanged if one of the
following is true:
|EPERM||The effective user ID does not match the owner of the file, and the process does not have appropriate privileges.|
|EROFS||The named file resides on a read-only file system.|
|EIO||An I/O error occurred during the operation.|
If NFS is installed on your system, the chmod and
fchmod subroutines can also be unsuccessful if the following is
|ESTALE||The root or current directory of the process is located in a virtual file system that has been unmounted.|
|ETIMEDOUT||The connection timed out.|
Access Control: The invoker must have search permission for all components of the Path prefix.
If you receive the EBUSY error, toggle the enforced locking attribute in the Mode parameter and retry your operation. The enforced locking attribute should never be used on a file that is part of the Trusted Computing Base.
These subroutines are part of Base Operating System (BOS) Runtime.
The acl_chg (acl_chg or acl_fchg Subroutine) subroutine, acl_get (acl_get or acl_fget Subroutine) subroutine, acl_put (acl_put or acl_fput Subroutine) subroutine, acl_set (acl_set or acl_fset Subroutine) subroutine, chacl (chacl or fchacl Subroutine) subroutine, statacl subroutine, stat subroutine.
The aclget command, aclput command, chmod command.
List of Security and Auditing Subroutines and Subroutines Overview in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.