Copyright (C) 2002 Chad David <davidc@FreeBSD.org>. All rights reserved. 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 fo...
NAMEkenv - kernel environment
SYNOPSISIn kenv.h Ft int Fn kenv int action const char *name char *value int len
DESCRIPTIONThe Fn 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 Fa action argument can be one of the following:
- Returns the value associated with the named kernel environment variable. If the variable is not found, -1 is returned and the global variable errno is set to Er ENOENT . Only the number of bytes available in Fa value are copied out.
- Sets or adds a new kernel environment variable. This option is only available to the superuser.
- Unsets the kernel environment variable Fa name . If the variable does not exist, -1 is returned and the global variable errno is set to Er EINVAL . This option is only available to the superuser.
- Dumps as much of the kernel environment as will fit in Fa value . If Fa value is NULL Fn kenv will return the number of bytes required to copy out the entire environment.
The Fa name argument is the name of the environment variable to be affected. In the case of KENV_DUMP it is ignored.
The Fa value argument contains either the value to set the environment variable Fa name to in the case of KENV_SET or it points to the location where Fn kenv should copy return data to in the case of KENV_DUMP and KENV_GET If Fa value is NULL in the case of KENV_DUMP Fn kenv will return the number of bytes required to copy out the entire environment.
The Fa len argument indicates how many bytes of storage Fa value points to.
RETURN VALUESThe Fn kenv system call returns 0 if successful in the case of KENV_SET and KENV_UNSET and the number of bytes copied into Fa 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.
ERRORSThe Fn kenv system call will fail if:
- Bq Er EINVAL
- The Fa action argument is not a valid option, or the length of the Fa value is less than 1 for a KENV_SET
- Bq Er ENOENT
- no value could be found for Fa name for a KENV_SET or KENV_UNSET
- Bq Er EPERM
- a user other than the superuser attempted to set or unset a kernel environment variable.
- Bq Er EFAULT
- bad address was encountered while attempting to copy in user arguments, or copy out value(s).
- Bq Er ENAMETOOLONG
- the name of a variable supplied by the user is longer than KENV_MNAMELEN or the value of a variable is longer than KENV_MVALLEN
AUTHORSAn -nosplit This manual page was written by An Chad David Aq davidc@FreeBSD.org .
The Fn kenv system call was written by An Maxime Henrion Aq mux@FreeBSD.org .