COHERENT manpages

This page displays the COHERENT manpage for umask() [Set file-creation mask].

List of available manpages
Index


umask() -- System Call (libc)

Set file-creation mask
#include <sys/stat.h>
int umask(mask)
int mask;

umask()  allows  a  process to  restrict  the  mode  of  files it  creates.
Commands that  create files should specify the  maximum reasonable mode.  A
parent  (e.g. the  shell sh)  usually calls umask()  to restrict  access to
files created by subsequent commands.

mask should be constructed from any of the permission bits found by chmod()
(the low-order nine bits).  When a file is created with creat() or mknod(),
every bit set in the mask is zeroed in mode; thus, bits set in mask specify
permissions that will be denied.

umask() returns the old value of the file-creation mask.

Example

Setting mask  to octal 022 (i.e.,  000 010 010) causes  a file created with
mode octal 0666 to actually have permissions of

    rw- r-- r--

Setting mask  to zero (i.e., 000  000 000) causes a  file created with mode
octal 0666 to actually have permissions of

    rw- rw- rw-

See Also

creat(),
libc,
mknod(),
sh,
stat.h
POSIX Standard, §5.3.3

Notes

A  file's default  permission cannot  be set to  execute regardless  of the
value of mask.