'"macro stdmacro
chmod - change access permission mode of file
#include <sys/types.h>
#include <sys/stat.h>
chmod() sets the access permission portion of the mode of the file whose name is given by path to the bit pattern contained in mode . Modes are constructed by ORing the access permission bits.
The effective user ID of the thread must match the owner of the file or the thread must have the appropriate privilege to change the mode of a file.
If the thread is not privileged and the file is not a directory, mode bit 01000 (save text image on execution) is cleared.
If a directory is writable and has S_ISVTX (the sticky bit) set, files within that directory can be removed or renamed only if one or more of the following is true (see unlink (2) and rename (2)):
(bu the user owns the file (bu the user owns the directory (bu the file is writable by the user (bu the user is a privileged user
If a directory has the set group ID bit set, a given file created within that directory will have the same group ID as the directory, if that group ID is part of the group ID set of the thread that created the file. Otherwise, the newly created file's group ID will be set to the effective group ID of the creating thread.
If the mode bit 02000 (set group IDon execution) is set and the mode bit 00010 (execute or search by group) is not set, mandatory file/record locking will exist on a regular file. This may affect future calls to open (2), creat (2), read (2), and write (2) on this file.
Upon successful completion, chmod() marks for update the st_ctime field of the file.
Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error.
chmod() will fail and the file mode will be unchanged if one or more of the following are true:
fchmod() will fail and the file mode will be unchanged if:
open , read , stat , write , stat