UMASK(3)                   POSIX Programmer's Manual                  UMASK(3)



PPRROOLLOOGG
       This manual page is part of the POSIX Programmer's Manual.  The OS
       implementation of this interface may differ (consult the corresponding
       OS manual page for details of OS behavior), or the interface may not be
       implemented on OS.

NNAAMMEE
       umask -- set and get the file mode creation mask

SSYYNNOOPPSSIISS
       #include <sys/stat.h>

       mode_t umask(mode_t _c_m_a_s_k);

DDEESSCCRRIIPPTTIIOONN
       The _u_m_a_s_k() function shall set the file mode creation mask of the
       process to _c_m_a_s_k and return the previous value of the mask. Only the
       file permission bits of _c_m_a_s_k (see _<_s_y_s_/_s_t_a_t_._h_>) are used; the meaning
       of the other bits is implementation-defined.

       The file mode creation mask of the process is used to turn off
       permission bits in the _m_o_d_e argument supplied during calls to the
       following functions:

        *  _o_p_e_n(), _o_p_e_n_a_t(), _c_r_e_a_t(), _m_k_d_i_r(), _m_k_d_i_r_a_t(), _m_k_f_i_f_o(), and
           _m_k_f_i_f_o_a_t()

        *  _m_k_n_o_d(), _m_k_n_o_d_a_t()

        *  _m_q___o_p_e_n()

        *  _s_e_m___o_p_e_n()

       Bit positions that are set in _c_m_a_s_k are cleared in the mode of the
       created file.

RREETTUURRNN VVAALLUUEE
       The file permission bits in the value returned by _u_m_a_s_k() shall be the
       previous value of the file mode creation mask. The state of any other
       bits in that value is unspecified, except that a subsequent call to
       _u_m_a_s_k() with the returned value as _c_m_a_s_k shall leave the state of the
       mask the same as its state before the first call, including any
       unspecified use of those bits.

EERRRROORRSS
       No errors are defined.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

EEXXAAMMPPLLEESS
       None.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

RRAATTIIOONNAALLEE
       Unsigned argument and return types for _u_m_a_s_k() were proposed. The
       return type and the argument were both changed to mmooddee__tt.

       Historical implementations have made use of additional bits in _c_m_a_s_k
       for their implementation-defined purposes. The addition of the text
       that the meaning of other bits of the field is implementation-defined
       permits these implementations to conform to this volume of
       POSIX.1-2017.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _c_r_e_a_t(), _e_x_e_c, _m_k_d_i_r(), _m_k_f_i_f_o(), _m_k_n_o_d(), _m_q___o_p_e_n(), _o_p_e_n(),
       _s_e_m___o_p_e_n()

       The Base Definitions volume of POSIX.1-2017, <<ssyyss__ssttaatt..hh>>,
       <<ssyyss__ttyyppeess..hh>>

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1-2017, Standard for Information Technology --
       Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the
       Institute of Electrical and Electronics Engineers, Inc and The Open
       Group.  In the event of any discrepancy between this version and the
       original IEEE and The Open Group Standard, the original IEEE and The
       Open Group Standard is the referee document. The original Standard can
       be obtained online at http://www.opengroup.org/unix/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2017                             UMASK(3)
