Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

umask - get and set file mode creation mask

&pagelevel(4)&pagelevel

Syntax

#include <sys/stat.h>

Optional
#include <sys/types.h> (End)

mode_t umask (mode_t cmask);

Description

umask() sets the file mode creation mask of the process to cmask and returns the previous value of the mask. Only the file permission bits of cmask (see sys/stat.h) are used; the other bits are ignored.

The file mode creation mask of the process is used by the functions open(), creat(), mkdir() and mkfifo() to remove access permissions in mode. Bit positions that are set in cmask are cleared in the access permissions of the created file.

The state of the mask before the first call to umask(), including all other bits, can be restored by a subsequent call to umask() with the return value of the first call as the argument.

Return val.

If the user ID is 0, the default value is 022 (octal); otherwise, 066.

Previous value of the file mode creation mask if successful. The other bits are ignored. A subsequent call to umask() with the return value of the preceding call as cmask will reset the mask to the same state as before the first call.

Notes

umask() is executed only for POSIX files

See also

creat(), mkdir(), mkfifo(), open(), sys/stat.h, sys/types.h.