Changes the file protection of a file. Format #include <stat.h> int chmod (const char *file_spec, mode_t mode);
1 – Arguments
file_spec The name of an OpenVMS or UNIX style file specification. mode A file protection. Modes are constructed by performing a bitwise OR on any of the values shown in File Protection Values and Their Meanings. Table REF-2 File Protection Values and Their Meanings Value Privilege 0400 OWNER:READ 0200 OWNER:WRITE 0100 OWNER:EXECUTE 0040 GROUP:READ 0020 GROUP:WRITE 0010 GROUP:EXECUTE 0004 WORLD:READ 0002 WORLD:WRITE 0001 WORLD:EXECUTE When you supply a mode value of 0, the chmod function gives the file the user's default file protection. The system is given the same privileges as the owner. A WRITE privilege also implies a DELETE privilege.
2 – Description
You must have a WRITE privilege for the file specified to change the mode. The C RTL does not support the S_ISVTX bit. Setting the S_ISVTX mode has no effect.
3 – Return Values
0 Indicates that the mode is successfully changed. -1 Indicates that the change attempt has failed.