1SETMODE(3)               BSD Library Functions Manual               SETMODE(3)
2

NAME

4     getmode, setmode — modify mode bits
5

LIBRARY

7     Utility functions from BSD systems (libbsd, -lbsd)
8

SYNOPSIS

10     #include <unistd.h>
11
12     mode_t
13     getmode(const void *set, mode_t mode);
14
15     void *
16     setmode(const char *mode_str);
17

DESCRIPTION

19     The getmode() function returns a copy of the file permission bits mode as
20     altered by the values pointed to by set.  While only the mode bits are
21     altered, other parts of the file mode may be examined.
22
23     The setmode() function takes an absolute (octal) or symbolic value, as
24     described in chmod(1), as an argument and returns a pointer to mode val‐
25     ues to be supplied to getmode().  Because some of the symbolic values are
26     relative to the file creation mask, setmode() may call umask(2).  If this
27     occurs, the file creation mask will be restored before setmode() returns.
28     If the calling program changes the value of its file creation mask after
29     calling setmode(), setmode() must be called again if getmode() is to mod‐
30     ify future file modes correctly.
31
32     If the mode passed to setmode() is invalid or if memory cannot be allo‐
33     cated for the return value, setmode() returns NULL.
34
35     The value returned from setmode() is obtained from malloc() and should be
36     returned to the system with free() when the program is done with it, gen‐
37     erally after a call to getmode().
38

ERRORS

40     The setmode() function may fail and set errno for any of the errors spec‐
41     ified for the library routine malloc(3).
42

SEE ALSO

44     chmod(1), stat(2), umask(2), malloc(3)
45

HISTORY

47     The getmode() and setmode() functions first appeared in 4.4BSD.
48
49BSD                             April 28, 1995                             BSD
Impressum