ReactOS 0.4.16-dev-1025-gd3456f5
umask.cpp
Go to the documentation of this file.
1/***
2*umask.c - set file permission mask
3*
4* Copyright (c) Microsoft Corporation. All rights reserved.
5*
6*Purpose:
7* defines _umask() - sets file permission mask of current process*
8* affecting files created by creat, open, or sopen.
9*
10*******************************************************************************/
11
13#include <sys/stat.h>
14
15extern "C" { int _umaskval = 0; }
16
17/***
18*errno_t _umask(mode, poldmode) - set the file mode mask
19*
20*Purpose :
21* Works similiar to umask except it validates input params.
22*
23*
24*******************************************************************************/
25
27 int const mode,
28 int* const old_mode
29 )
30{
31 _VALIDATE_RETURN_ERRCODE(old_mode != nullptr, EINVAL);
32 *old_mode = _umaskval;
34
36 return 0;
37}
38
39/***
40*int _umask(mode) - set the file mode mask
41*
42*Purpose:
43* Sets the file-permission mask of the current process* which
44* modifies the permission setting of new files created by creat,
45* open, or sopen.
46*
47*Entry:
48* int mode - new file permission mask
49* may contain _S_IWRITE, _S_IREAD, _S_IWRITE | _S_IREAD.
50* The S_IREAD bit has no effect under Win32
51*
52*Exit:
53* returns the previous setting of the file permission mask.
54*
55*Exceptions:
56*
57*******************************************************************************/
58extern "C" int __cdecl _umask(int const mode)
59{
60 // Silently ignore non-Windows modes:
61 int const masked_mode = mode & (_S_IREAD | _S_IWRITE);
62
63 int old_mode = 0;
64 _umask_s(masked_mode, &old_mode);
65 return old_mode;
66}
#define EINVAL
Definition: acclib.h:90
#define __cdecl
Definition: accygwin.h:79
#define _S_IWRITE
Definition: cabinet.h:33
#define _S_IREAD
Definition: cabinet.h:34
GLenum mode
Definition: glext.h:6217
#define _VALIDATE_RETURN_ERRCODE(expr, errorcode)
int errno_t
Definition: corecrt.h:615
errno_t __cdecl _umask_s(int const mode, int *const old_mode)
Definition: umask.cpp:26
int __cdecl _umask(int const mode)
Definition: umask.cpp:58
int _umaskval
Definition: umask.cpp:15