umask(2) umask(2)NAME umask - set and get file creation mask SYNOPSIS #include <sys/types.h> #include <sys/stat.h> mode_t umask(cmask) mode_t cmask; DESCRIPTION umask sets the file-mode-creation mask of the calling pro- cess to cmask and returns the previous value of the mask. Only the low-order 9 bits of cmask and the file-mode- creation mask are used. The file-mode-creation mask is used whenever a file is created by creat(2), mknod(2) or open(2). The actual mode (see chmod(2)) of the newly created file is the difference between the given mode and cmask. In other words, cmask shows the bits to be turned off when a new file is created. For the POSIX environment, the following constants for cmask are defined in <sys/stat.h>: S_IRUSR read permission, owner S_IWUSR write permission, owner S_IXUSR execute/search permission, owner S_IRGRP read permission, group S_IWGRP write permission, group S_IXGRP execute/search permission, group S_IRUSR read permission, others S_IWUSR write permission, others S_IXUSR execute/search permission, others The previous value of cmask is returned by the call. The value is initially 022, which is an octal ``mask'' number representing the complement of the desired mode. The value 022 here means that no permissions are withheld from the owner, but write permission is forbidden to the group and to others. Its complement, the mode of the file, would be 0755. The file-mode-creation mask is inherited by child processes. April, 1990 1
umask(2) umask(2)RETURN VALUE The previous value of the file-mode-creation mask is re- turned. SEE ALSO csh(1), ksh(1), chmod(1), mkdir(1), sh(1), chmod1(2), creat(2), mknod(2), open(2). 2 April, 1990