CHMOD(S) XENIX System V CHMOD(S)
Name
chmod - Changes mode of a file.
Syntax
int chmod (path, mode)
char *path;
int mode;
Description
path points to a pathname naming a file. chmod sets the
access permission portion of the named file's mode. It sets
the access permission portion according to the bit pattern
contained in mode.
Access permission bits for mode can be formed by adding any
combination of the following:
04000 Set user ID on execution
02000 Set group ID on execution
01000 Save text image after execution
00400 Read by owner
00200 Write by owner
00100 Execute (or search if a directory) by owner
00040 Read by group
00020 Write by group
00010 Execute (or search) by group
00004 Read by others
00002 Write by others
00001 Execute (or search) by others
To change the mode of a file, the effective user ID of the
process must match the owner of the file or must be super-
user.
If the effective user ID of the process is not super-user,
mode bit 01000 (save text image on execution) is cleared.
If the effective user ID of the process is not super-user or
the effective group ID of the process does not match the
group ID of the file, mode bit 02000 (set group ID on
execution) is cleared.
If an executable file is prepared for sharing, when its last
user terminates, mode bit 01000 prevents the system from
abandoning the swap-space image of the program-text portion
of the file. Thus, when the next user executes the file,
the text need not be read from the file system but can
simply be swapped in, saving time. Many systems have
relatively small amounts of swap space, and the same-text
bit should be used sparingly, if at all.
chmod will fail and the file mode will be unchanged if one
Page 1 (printed 8/7/87)
CHMOD(S) XENIX System V CHMOD(S)
or more of the following are true:
A component of the path prefix is not a directory.
[ENOTDIR]
The named file does not exist. [ENOENT]
Search permission is denied on a component of the path
prefix. [EACCES]
The effective user ID does not match the owner of the
file and the effective user ID is not super-user.
[EPERM]
The named file resides on a read-only file system.
[EROFS]
path points outside the process' allocated address
space. [EFAULT]
Return Value
Upon successful completion, a value of 0 is returned.
Otherwise, a value of -1 is returned and errno is set to
indicate the error.
See Also
chown(S), mknod(S)
Page 2 (printed 8/7/87)