1UMASK(2) Linux Programmer's Manual UMASK(2)
2
3
4
6 umask - set file mode creation mask
7
9 #include <sys/types.h>
10 #include <sys/stat.h>
11
12 mode_t umask(mode_t mask);
13
15 umask() sets the calling process's file mode creation mask (umask) to
16 mask & 0777 (i.e., only the file permission bits of mask are used), and
17 returns the previous value of the mask.
18
19 The umask is used by open(2), mkdir(2), and other system calls that
20 create files to modify the permissions placed on newly created files or
21 directories. Specifically, permissions in the umask are turned off
22 from the mode argument to open(2) and mkdir(2).
23
24 The constants that should be used to specify mask are described under
25 stat(2).
26
27 The typical default value for the process umask is S_IWGRP | S_IWOTH
28 (octal 022). In the usual case where the mode argument to open(2) is
29 specified as:
30
31 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
32
33 (octal 0666) when creating a new file, the permissions on the resulting
34 file will be:
35
36 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
37
38 (because 0666 & ~022 = 0644; i.e., rw-r--r--).
39
41 This system call always succeeds and the previous value of the mask is
42 returned.
43
45 SVr4, 4.3BSD, POSIX.1-2001.
46
48 A child process created via fork(2) inherits its parent's umask. The
49 umask is left unchanged by execve(2).
50
51 The umask setting also affects the permissions assigned to POSIX IPC
52 objects (mq_open(3), sem_open(3), shm_open(3)), FIFOs (mkfifo(3)), and
53 Unix domain sockets (unix(7)) created by the process. The umask does
54 not affect the permissions assigned to System V IPC objects created by
55 the process (using msgget(2), semget(2), shmget(2)).
56
58 chmod(2), mkdir(2), open(2), stat(2)
59
61 This page is part of release 3.25 of the Linux man-pages project. A
62 description of the project, and information about reporting bugs, can
63 be found at http://www.kernel.org/doc/man-pages/.
64
65
66
67Linux 2008-01-09 UMASK(2)