setmode()

NAME

getmode(), setmode() - modify mode bits

SYNOPSIS

#include <sys/types.h>
#include <unistd.h>

mode_t getmode (const void *set, mode_t mode) void *setmode (const char *mode_str)

DESCRIPTION

The getmode(3) function returns a copy of the file permission bits mode as altered by the values pointed to by set. While only the mode bits are altered, other parts of the file mode may be examined.

The setmode(3) function takes an absolute (octal) or symbolic value, as described in chmod(2), as an argument and returns a pointer to mode values to be supplied to getmode(3). Because some of the symbolic values are relative to the file creation mask, setmode(3) may call umask(2). If this occurs, the file creation mask will be restored before setmode(3) returns. If the calling program changes the value of its file creation mask after calling setmode(3), setmode(3) must be called again if getmode(3) is to modify future file modes correctly.

If the mode passed to setmode(3) is invalid, setmode(3) returns NULL.

ERRORS

The setmode(3) function may fail and set errno for any of the errors specified for the library routine malloc(3).

SEE ALSO

chmod(2)

stat(2)

umask(2)

malloc(3)