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.
17
18 The umask is used by open(2), mkdir(2), and other system calls that
19 create files to modify the permissions placed on newly created files or
20 directories. Specifically, permissions in the umask are turned off
21 from the mode argument to open(2) and mkdir(2).
22
23 The constants that should be used to specify mask are described under
24 stat(2).
25
26 The typical default value for the process umask is S_IWGRP | S_IWOTH
27 (octal 022). In the usual case where the mode argument to open(2) is
28 specified as:
29
30 S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH
31
32 (octal 0666) when creating a new file, the permissions on the resulting
33 file will be:
34
35 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
36
37 (because 0666 & ~022 = 0644; i.e., rw-r--r--).
38
40 This system call always succeeds and the previous value of the mask is
41 returned.
42
44 A child process created via fork(2) inherits its parent's umask. The
45 umask is left unchanged by execve(2).
46
48 SVr4, 4.3BSD, POSIX.1-2001.
49
51 chmod(2), mkdir(2), open(2), stat(2)
52
53
54
55Linux 2006-05-13 UMASK(2)