Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ chmod(2) — Ultrix-11 3.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(1)

chown(2)

chmod(2)

NAME

chmod − change mode of a file

SYNTAX

int chmod(name, mode)
char *name;
int mode;

DESCRIPTION

The chmod system call changes the mode of file name (null-terminated string) to mode.  The specified mode is constructed by a bitwise or of the following:

04000   Set user ID on execution
02000   Set group ID on execution
01000   Save text image after execution
00400   Read permission by owner
00200   Write permission by owner
00100   Execute (search on directory) by owner
00040   Read permission by group
00020   Write Permission by group
00010   Execute (search on directory) by group
00004   Read permission by others
00002   Write permission by others
00001   Execute (search on directory) by others

If an executable file is set up for sharing (the ld command with either −i or −n option was specified), then mode 1000 prevents the system from abandoning 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 this program, its text need not be read from the file system but can simply be swapped in (saves time).  Ability to set this bit is restricted to the superuser because swap space is consumed by the images.  It is only worth while for heavily used commands. 

If the effective user ID of the process is not superuser and 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.  (This prevents an ordinary user from making himself an effective member of a group to which they do not belong.  Similarly, if the chown call is invoked other than by the superuser, the set-user-ID and set-group-ID bits of the file mode will be cleared.) 

RESTRICTIONS

Only the owner of a file (or the superuser) may change the mode.  Only the superuser can set the 1000 mode. 

RETURN VALUE

If unsuccessful, returns a −1, and the global variable errno indicates the error code. 

DIAGNOSTICS

The chmod call will fail if:

[EACCES] Search permission is denied on a component of the path prefix. 

[EFAULT] The specified name points outside the process’s allocated address space. 

[ENFILE] There is insufficient system space to contain the inode. 

[ENOENT] Either the named file or an element within the named file does not exist. 

[ENOTDIR] A component of the path prefix is not a directory. 

[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. 

ASSEMBLER

(chmod = 15.) 
sys chmod; name; mode

SEE ALSO

chmod(1), chown(2)

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