chmod() COHERENT System Call chmod() Change file-protection modes #include <sys/stat.h> chmod(file, mode) char *file; int mode; chmod sets the mode bits for file. The mode bits include protec- tion bits, the set-user-id bit, and the sticky bit. mode is constructed from the logical OR of the following, which are defined symbolically in the header file stat.h: 04000 Set user identifier 02000 Set group identifier 01000 Save file on swap device (``sticky bit'') 00400 Read permission for owner 00200 Write permission for owner 00100 Execute permission for owner 00040 Read permission for members of owner's group 00020 Write permission for members of owner's group 00010 Execute permission for members of owner's group 00004 Read permission for other users 00002 Write permission for other users 00001 Execute permission for other users For directories, some protection bits have a different meaning: write permission means files may be created and removed, whereas execute permission means that the directory may be searched. The save-text bit (or ``sticky bit'') is a flag to the system when it executes a shared for of a load module. After the system runs the program, it leaves shared segments on the swap device to speed subsequent reinvocation of the program. Setting this bit is restricted to the superuser (to control depletion of swap space which might result from overuse). Only the owner of a file or the superuser may change its mode. ***** See Also ***** COHERENT system calls, creat() ***** Diagnostics ***** chmod returns -1 for errors, such as file being nonexistent or the invoker being neither the owner nor the superuser. COHERENT Lexicon Page 1