Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ chmod(2) — A/UX 2.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

chown(2)

open(2)

stat(2)

mknod(2)

umask(2)




chmod(2) chmod(2)
NAME chmod - change mode of file SYNOPSIS #include <sys/types.h> #include <sys/stat.h> int chmod(path, mode) char *path; mode_t mode; DESCRIPTION chmod sets the access permission portion of the named file's mode according to the bit pattern contained in mode. The path points to a pathname naming a file. Access permission bits are interpreted as follows: 04000 Set effective user ID on execution. 02000 Set effective group ID on execution. 01000 Save text image after execution. 00400 Read by owner. 00200 Write by owner. 00100 Execute (search if a directory) by owner. 00070 Read, write, execute (search) by group. 00007 Read, write, execute (search) by others. The effective user ID of the calling process must match the owner of the file or be the superuser to change the mode of a file. If the effective user ID of the process is not the su- peruser, mode bit 01000 (save text image after execution) is cleared. If the effective user ID of the process is not the superuser and the effective group ID of the process does not match the group ID of the file, mode bit 02000 (set the effective group ID on execution) is cleared. If an executable file is prepared for sharing (see the cc -n option), then mode bit 01000 prevents the system from aban- doning the swap-space image of the program-text portion of the file when its last user terminates. Thus, when the next user of the file executes it, the text need not be read from the file system but can simply be swapped in, saving time. April, 1990 1



chmod(2) chmod(2)
Changing the owner of a file turns off the mode bit 04000 (set user ID), unless the superuser does it. This makes the system somewhat more secure at the expense of a degree of compatibility. RETURN VALUE On successful completion, a value of 0 is returned. Other- wise, a value of -1 is returned and errno is set to indicate the error. ERRORS chmod will fail and the file mode will be unchanged if one or more of the following are true: [ENOTDIR] A component of the path prefix is not a direc- tory. [ENAMETOOLONG] A component of a pathname exceeded NAME_MAX characters, or an entire pathname exceeded PATH_MAX. [ELOOP] Too many symbolic links were encountered in translating a pathname. [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 superuser. [EROFS] The named file resides on a read-only file system. [EFAULT] The path points outside the allocated address space of the process. SEE ALSO chmod(1), chown(2), open(2), stat(2), mknod(2), umask(2). 2 April, 1990

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026