chmod

Changes the file protection of a file.

Format

#include  <stat.h>

int chmod  (const char *file_spec, mode_t mode);

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 Table 4.

Table 4 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.

Description

You must have a WRITE privilege for the file specified to change the mode.

Return Values
Indicates that the mode is successfully changed. 
-1  Indicates that the change attempt has failed. 


Previous Page | Next Page | Table of Contents | Index