2002-04-18 16:45:57 +00:00
|
|
|
.\"
|
2002-04-19 11:24:02 +00:00
|
|
|
.\" Copyright (C) 2002 Chad David <davidc@FreeBSD.org>. All rights reserved.
|
2002-04-18 16:45:57 +00:00
|
|
|
.\"
|
|
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
|
|
.\" modification, are permitted provided that the following conditions
|
|
|
|
.\" are met:
|
|
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
|
|
.\" notice(s), this list of conditions and the following disclaimer as
|
|
|
|
.\" the first lines of this file unmodified other than the possible
|
|
|
|
.\" addition of one or more copyright notices.
|
|
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
.\" notice(s), this list of conditions and the following disclaimer in the
|
|
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
|
|
|
|
.\" EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
.\" DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY
|
|
|
|
.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
.\" (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
|
|
|
.\" DAMAGE.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2017-02-21 19:51:41 +00:00
|
|
|
.Dd February 20, 2017
|
2002-04-18 16:45:57 +00:00
|
|
|
.Dt KENV 2
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm kenv
|
|
|
|
.Nd kernel environment
|
|
|
|
.Sh LIBRARY
|
|
|
|
.Lb libc
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In kenv.h
|
|
|
|
.Ft int
|
|
|
|
.Fn kenv "int action" "const char *name" "char *value" "int len"
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
|
|
|
.Fn kenv
|
2002-12-18 09:22:32 +00:00
|
|
|
system call manipulates kernel environment variables.
|
2002-04-18 16:45:57 +00:00
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fa action
|
2002-12-19 09:40:28 +00:00
|
|
|
argument can be one of the following:
|
2002-04-19 11:24:02 +00:00
|
|
|
.Bl -tag -width ".Dv KENV_UNSET"
|
2002-04-18 16:45:57 +00:00
|
|
|
.It Dv KENV_GET
|
2017-02-21 19:51:41 +00:00
|
|
|
Get the
|
|
|
|
.Fa value
|
|
|
|
of the variable with the given
|
|
|
|
.Fa name .
|
|
|
|
The size of the
|
2002-04-18 16:45:57 +00:00
|
|
|
.Fa value
|
2017-02-21 19:51:41 +00:00
|
|
|
buffer is given by
|
|
|
|
.Fa len ,
|
|
|
|
which should be at least
|
|
|
|
.Dv KENV_MVALLEN
|
|
|
|
+ 1 bytes to avoid truncation and to ensure NUL termination.
|
2002-04-18 16:45:57 +00:00
|
|
|
.It Dv KENV_SET
|
2017-02-21 19:51:41 +00:00
|
|
|
Set or add a variable.
|
|
|
|
The
|
|
|
|
.Fa name
|
|
|
|
and
|
|
|
|
.Fa value
|
|
|
|
are limited to
|
|
|
|
.Dv KENV_MNAMELEN
|
|
|
|
and
|
|
|
|
.Dv KENV_MVALLEN
|
|
|
|
characters, respectively
|
|
|
|
.Pq not including the NUL terminator.
|
|
|
|
The
|
|
|
|
.Fa len
|
|
|
|
argument indicates the length of the
|
|
|
|
.Fa value
|
|
|
|
and must include the NUL terminator.
|
2002-04-19 11:24:02 +00:00
|
|
|
This option is only available to the superuser.
|
2002-04-18 16:45:57 +00:00
|
|
|
.It Dv KENV_UNSET
|
2017-02-21 19:51:41 +00:00
|
|
|
Unset the variable with the given
|
2002-04-18 16:45:57 +00:00
|
|
|
.Fa name .
|
2017-02-21 19:51:41 +00:00
|
|
|
The
|
|
|
|
.Fa value
|
|
|
|
and
|
|
|
|
.Fa len
|
|
|
|
arguments are ignored.
|
2002-04-18 16:45:57 +00:00
|
|
|
This option is only available to the superuser.
|
|
|
|
.It Dv KENV_DUMP
|
2017-02-21 19:51:41 +00:00
|
|
|
Dump as much of the kernel environment as will fit in
|
|
|
|
.Fa value ,
|
|
|
|
whose size is given in
|
|
|
|
.Fa len .
|
2002-04-18 16:45:57 +00:00
|
|
|
If
|
|
|
|
.Fa value
|
|
|
|
is
|
|
|
|
.Dv NULL ,
|
|
|
|
.Fn kenv
|
|
|
|
will return the number of bytes required to copy out the entire environment.
|
|
|
|
The
|
|
|
|
.Fa name
|
2017-02-21 19:51:41 +00:00
|
|
|
is ignored.
|
|
|
|
.El
|
2002-04-18 16:45:57 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
The
|
|
|
|
.Fn kenv
|
2002-12-18 09:22:32 +00:00
|
|
|
system call returns 0 if successful in the case of
|
2002-04-18 16:45:57 +00:00
|
|
|
.Dv KENV_SET
|
|
|
|
and
|
2002-04-19 11:24:02 +00:00
|
|
|
.Dv KENV_UNSET ,
|
2002-04-18 16:45:57 +00:00
|
|
|
and the number of bytes copied into
|
|
|
|
.Fa value
|
|
|
|
in the case of
|
|
|
|
.Dv KENV_DUMP
|
|
|
|
and
|
|
|
|
.Dv KENV_GET .
|
2002-04-19 11:24:02 +00:00
|
|
|
If an error occurs, a value of \-1 is returned and
|
|
|
|
the global variable
|
2002-04-18 16:45:57 +00:00
|
|
|
.Va errno
|
|
|
|
is set to indicate the error.
|
|
|
|
.Sh ERRORS
|
2002-12-18 09:22:32 +00:00
|
|
|
The
|
2002-04-18 16:45:57 +00:00
|
|
|
.Fn kenv
|
2002-12-18 09:22:32 +00:00
|
|
|
system call
|
2002-04-18 16:45:57 +00:00
|
|
|
will fail if:
|
|
|
|
.Bl -tag -width Er
|
|
|
|
.It Bq Er EINVAL
|
2002-12-19 09:40:28 +00:00
|
|
|
The
|
2002-04-18 16:45:57 +00:00
|
|
|
.Fa action
|
2002-12-19 09:40:28 +00:00
|
|
|
argument
|
2002-04-18 16:45:57 +00:00
|
|
|
is not a valid option, or the length of the
|
|
|
|
.Fa value
|
|
|
|
is less than 1 for a
|
|
|
|
.Dv KENV_SET .
|
|
|
|
.It Bq Er ENOENT
|
2017-02-21 19:51:41 +00:00
|
|
|
No value could be found for
|
2002-04-18 16:45:57 +00:00
|
|
|
.Fa name
|
|
|
|
for a
|
2017-02-21 19:51:41 +00:00
|
|
|
.Dv KENV_GET
|
2002-04-18 16:45:57 +00:00
|
|
|
or
|
|
|
|
.Dv KENV_UNSET .
|
|
|
|
.It Bq Er EPERM
|
2017-02-21 19:51:41 +00:00
|
|
|
A user other than the superuser attempted to set or unset a kernel
|
2002-04-18 16:45:57 +00:00
|
|
|
environment variable.
|
|
|
|
.It Bq Er EFAULT
|
2017-02-21 19:51:41 +00:00
|
|
|
A bad address was encountered while attempting to copy in user arguments
|
2002-04-18 16:45:57 +00:00
|
|
|
or copy out value(s).
|
|
|
|
.It Bq Er ENAMETOOLONG
|
2017-02-21 19:51:41 +00:00
|
|
|
The
|
|
|
|
.Fa name
|
|
|
|
or the
|
|
|
|
.Fa value
|
|
|
|
is longer than
|
2002-04-18 16:45:57 +00:00
|
|
|
.Dv KENV_MNAMELEN
|
2017-02-21 19:51:41 +00:00
|
|
|
or
|
|
|
|
.Dv KENV_MVALLEN
|
|
|
|
characters, respectively, or
|
|
|
|
.Fa len
|
|
|
|
did not include the NUL terminator for a
|
|
|
|
.Dv KENV_SET .
|
2002-04-18 16:45:57 +00:00
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr kenv 1
|
|
|
|
.Sh AUTHORS
|
|
|
|
.An -nosplit
|
2005-06-30 13:18:15 +00:00
|
|
|
This manual page was written by
|
2014-06-23 08:25:03 +00:00
|
|
|
.An Chad David Aq Mt davidc@FreeBSD.org .
|
2002-04-18 16:45:57 +00:00
|
|
|
.Pp
|
2002-04-19 11:24:02 +00:00
|
|
|
The
|
2002-04-18 16:45:57 +00:00
|
|
|
.Fn kenv
|
|
|
|
system call was written by
|
2014-06-23 08:25:03 +00:00
|
|
|
.An Maxime Henrion Aq Mt mux@FreeBSD.org .
|