GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
KENV(2) FreeBSD System Calls Manual KENV(2)

kenv
kernel environment

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:

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.
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.
Unset the variable with the given name. The value and len arguments are ignored. This option is only available to the superuser.
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.
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.
Dump the static environment defined by the kernel config(5). The semantics are identical to KENV_DUMP_LOADER.

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:
[]
The action argument is not a valid option, or the length of the value is less than 1 for a KENV_SET.
[]
No value could be found for name for a KENV_GET or KENV_UNSET.
[]
The requested environment is not available for a KENV_DUMP_LOADER or KENV_DUMP_STATIC. The kernel is configured to destroy these environments by default.
[]
A user other than the superuser attempted to set or unset a kernel environment variable.
[]
A bad address was encountered while attempting to copy in user arguments or copy out value(s).
[]
The name or the value is longer than KENV_MNAMELEN or KENV_MVALLEN characters, respectively, or len did not include the NUL terminator for a KENV_SET.

kenv(1)

This manual page was written by Chad David <davidc@FreeBSD.org>.

The kenv() system call was written by Maxime Henrion <mux@FreeBSD.org>.

June 20, 2021 FreeBSD 13.1-RELEASE

Search for    or go to Top of page |  Section 2 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.