Standard C Library (libc, -lc)
#include
<kenv.h>
int
kenv(int
action, const char
*name, char *value,
int len);
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_GETENOENT. Only
the number of bytes available in value are copied
out.KENV_SETKENV_UNSETEINVAL. This
option is only available to the superuser.KENV_DUMPNULL,
kenv()
will return the number of bytes required to copy out the entire
environment.The name argument is the name of the
environment variable to be affected. In the case of
KENV_DUMP it is ignored.
The value argument contains
either the value to set the environment variable name
to in the case of KENV_SET, or it points to the
location where
kenv()
should copy return data to in the case of KENV_DUMP
and KENV_GET. If value is
NULL in the case of
KENV_DUMP, kenv() will
return the number of bytes required to copy out the entire environment.
The len argument indicates how many bytes of storage value points to.
The kenv() system call returns 0 if
successful in the case of KENV_SET and
KENV_UNSET, and the number of bytes copied into
value in the case of KENV_DUMP
and KENV_GET. If an error occurs, a value of -1 is
returned and the global variable errno is set to
indicate the error.
The kenv() system call will fail if:
EINVAL]KENV_SET.ENOENT]KENV_SET or
KENV_UNSET.EPERM]EFAULT]ENAMETOOLONG]KENV_MNAMELEN or the value of a variable is longer
than KENV_MVALLEN.This manual page was written by Chad David ⟨davidc@FreeBSD.org⟩.
The kenv() system call was written by
Maxime Henrion ⟨mux@FreeBSD.org⟩.