COHERENT manpages

This page displays the COHERENT manpage for chmod() [Change file-protection modes].

List of available manpages
Index


chmod() -- System Call (libc)

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 protection bits,
the set-user-id bit, and the sticky bit.

mode is constructed  from the logical OR of the  mode constants declared in
the header file stat.h, as follows:

     S_ISUID        Set user identifier on execution
     S_ISGID        Set group identifier on execution
     S_ISVTX        Save file on swap device (``sticky bit'')
     S_IRUSR        Read permission for owner
     S_IWUSR        Write permission for owner
     S_IXUSR        Execute permission for owner
     S_IRGRP        Read permission for members of owner's group
     S_IWGRP        Write permission for members of owner's group
     S_IXGRP        Execute permission for members of owner's group
     S_IROTH        Read permission for other users
     S_IWOTH        Write permission for other users
     S_IXOTH        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

creat(),
libc,
stat.h
POSIX Standard, §5.6.4

Diagnostics

chmod()  returns -1  for  errors, such  as  file being  nonexistent or  the
invoker being neither the owner nor the superuser.