summaryrefslogtreecommitdiffstats
path: root/private/crt32/misc/umask.c
blob: 9ca63a8763241e203a29f14706f024a915054d58 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/***
*umask.c - set file permission mask
*
*	Copyright (c) 1989-1991, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	defines _umask() - sets file permission mask of current process*
*	affecting files created by creat, open, or sopen.
*
*Revision History:
*	06-02-89   PHG	module created
*	03-16-90   GJF	Made calling type _CALLTYPE1, added #include
*			<cruntime.h> and fixed the copyright. Also, cleaned
*			up the formatting a bit.
*	04-05-90   GJF	Added #include <io.h>.
*	10-04-90   GJF	New-style function declarator.
*	01-17-91   GJF	ANSI naming.
*
*******************************************************************************/

#include <cruntime.h>
#include <internal.h>
#include <io.h>

/***
*int _umask(mode) - set the file mode mask
*
*Purpose:
*	Sets the file-permission mask of the current process* which
*	modifies the permission setting of new files created by creat,
*	open, or sopen.
*
*Entry:
*	int mode - new file permission mask
*		   may contain S_IWRITE, S_IREAD, S_IWRITE | S_IREAD.
*		   The S_IREAD bit has no effect under OS/2.
*
*Exit:
*	returns the previous setting of the file permission mask.
*
*Exceptions:
*
*******************************************************************************/

int _CALLTYPE1 _umask (
	int mode
	)
{
	register int oldmode;		/* old umask value */

	mode &= 0x180;			/* only user read/write permitted */
	oldmode = _umaskval;		/* remember old value */
	_umaskval = mode;		/* set new value */
	return oldmode; 		/* return old value */
}