CHMOD(2)
NAME
chmod − change mode of file
USAGE
chmod(path, mode)
char *path;
int mode;
fchmod(fd, mode)
int fd, mode;
DESCRIPTION
Chmod changes the mode of the file named by path (or described by the descriptor fd) to mode. Modes are constructed from the logical ‘or’ of the following:
04000 set user ID on execution
02000 set group ID on execution
00400 read by owner
00200 write by owner
00100 execute (search on directory) by owner
00070 read, write, execute (search) by group
00007 read, write, execute (search) by others
Only the owner of a file (or the super-user) may change the mode.
Writing or changing the owner of a file turns off the set-user-ID and set-group-ID bits. This makes the system somewhat more secure by protecting set-user-ID (set-group-ID) files from remaining set-user-ID (set-group-ID) if they are modified.
NOTES
DOMAIN/IX does not recognize write-only files, i.e., modes with 2 in either the owner, group, or others position. DOMAIN/IX will act as if the file is readable, even if mode is set to 2. However, DOMAIN/IX does change the mode to include read permission for the owner.
RETURN VALUE
Upon successful completion, chmod returns zero. Otherwise, the call returns −1 and sets errno to indicate the error.
ERRORS
Chmod will fail and the file mode will be unchanged if:
[EPERM] The argument contains a byte with the high-order bit set.
[ENOTDIR] A component of the path prefix is not a directory.
[ENOENT] The pathname is too long.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied on a component of the path prefix.
[EPERM] The effective user ID does not match the owner of the file and the effective user ID is not the super-user.
[EROFS] The named file resides on a read-only file system.
[EFAULT] Path points outside the process’ allocated address space.
[ELOOP] The call encountered too many symbolic links in translating the pathname.
Fchmod will fail if:
[EBADF] The descriptor is not valid.
[EINVAL] Fd refers to a socket, not to a file.
[EROFS] The file resides on a read-only file system.