umask

Creates a file protection mask that is used when a new file is created, and returns the previous mask value.

Format

#include  <stat.h>

mode_t umask  (mode_t mode_complement);

Argument

mode_complement
Shows which bits to turn off when a new file is created. See the description of chmod to determine what the bits represent.

Description

Initially, the file protection mask is set from the current process's default file protection. This is done when the C main program starts up or when DECC$CRTL_INIT (or VAXC$CRTL_INIT) is called. You can change this for all files created by your program by calling umask or you can use chmod to change the file protection on individual files. The file protection of a file created by open or creat is the bitwise AND of the open and creat mode argument with the complement of the value passed to umask on the previous call.
Note
The way to create files with OpenVMS RMS default protections using the UNIX system-call functions umask, mkdir, creat, and open is to call mkdir, creat, and open with a file-protection mode argument of 0777 in a program that never specifically calls umask. These default protections include correctly establishing protections based on ACLs, previous versions of files, and so on. In programs that do vfork/exec calls, the new process image inherits whether umask has ever been called or not from the calling process image. The umask setting and whether the umask function has ever been called are both inherited attributes.

Return Value
The old mask value. 


Previous Page | Next Page | Table of Contents | Index