The
kenv()
system call manipulates kernel environment variables.
It supports the well known userland actions of getting, setting and unsetting
environment variables, as well as the ability to dump all of the entries in
the kernel environment.
The
action
argument can be one of the following:
KENV_GET
|
Get the
value
of the variable with the given
name.
The size of the
value
buffer is given by
len,
which should be at least
KENV_MVALLEN
+ 1 bytes to avoid truncation and to ensure NUL termination.
|
KENV_SET
|
Set or add a variable.
The
name
and
value
are limited to
KENV_MNAMELEN
and
KENV_MVALLEN
characters, respectively
(not including the NUL terminator.)
The
len
argument indicates the length of the
value
and must include the NUL terminator.
This option is only available to the superuser.
|
KENV_UNSET
|
Unset the variable with the given
name.
The
value
and
len
arguments are ignored.
This option is only available to the superuser.
|
KENV_DUMP
|
Dump as much of the dynamic kernel environment as will fit in
value,
whose size is given in
len.
If
value
is
NULL,
kenv()
will return the number of bytes required to copy out the entire environment.
The
name
is ignored.
|
KENV_DUMP_LOADER
|
|
Dump the static environment provided by
loader(8),
with semantics identical to
KENV_DUMP.
Duplicate and malformed variables originally present in this environment are
discarded by the kernel and will not appear in the output.
|
KENV_DUMP_STATIC
|
|
Dump the static environment defined by the kernel
config(5).
The semantics are identical to
KENV_DUMP_LOADER.
|