Section: C Library Functions (3)Local indexUp BSD mandoc
NAME
getmodesetmode
- modify mode bits
LIBRARY
Lb libbsd
SYNOPSIS
In unistd.h
Ft mode_t
Fn getmode const void *set mode_t mode
Ft void *
Fn setmode const char *mode_str
DESCRIPTION
The
Fn getmode
function
returns a copy of the file permission bits
Fa mode
as altered by the values pointed to by
Fa set .
While only the mode bits are altered, other parts of the file mode
may be examined.
The
Fn setmode
function
takes an absolute (octal) or symbolic value, as described in
chmod(1),
as an argument
and returns a pointer to mode values to be supplied to
Fn getmode .
Because some of the symbolic values are relative to the file
creation mask,
Fn setmode
may call
umask(2).
If this occurs, the file creation mask will be restored before
Fn setmode
returns.
If the calling program changes the value of its file creation mask
after calling
Fn setmode ,
Fn setmode
must be called again if
Fn getmode
is to modify future file modes correctly.
If the mode passed to
Fn setmode
is invalid or if memory cannot be allocated for the return value,
Fn setmode
returns
NULL
The value returned from
Fn setmode
is obtained from
Fn malloc
and should be returned to the system with
Fn free
when the program is done with it, generally after a call to
Fn getmode .
ERRORS
The
Fn setmode
function
may fail and set errno for any of the errors specified for the library
routine
malloc(3).