FreeBSD kernel kern code
kern_environment.c File Reference
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/param.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/mutex.h>
#include <sys/priv.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/sysent.h>
#include <sys/sysproto.h>
#include <sys/libkern.h>
#include <sys/kenv.h>
#include <security/mac/mac_framework.h>
Include dependency graph for kern_environment.c:

Go to the source code of this file.

Macros

#define KENV_SIZE   512 /* Maximum number of environment strings */
 
#define KENV_CHECK
 

Functions

 __FBSDID ("$BSDSUniX$")
 
static MALLOC_DEFINE (M_KENV,"kenv","kernel environment")
 
static char * kernenv_next (char *)
 
int sys_kenv (struct thread *td, struct kenv_args *uap)
 
void init_static_kenv (char *buf, size_t len)
 
static void init_dynamic_kenv (void *data __unused)
 
 SYSINIT (kenv, SI_SUB_KMEM, SI_ORDER_ANY, init_dynamic_kenv, NULL)
 
void freeenv (char *env)
 
static char * _getenv_dynamic (const char *name, int *idx)
 
static char * _getenv_static (const char *name)
 
char * getenv (const char *name)
 
int testenv (const char *name)
 
static int setenv_static (const char *name, const char *value)
 
int setenv (const char *name, const char *value)
 
int unsetenv (const char *name)
 
int getenv_string (const char *name, char *data, int size)
 
int getenv_int (const char *name, int *data)
 
int getenv_uint (const char *name, unsigned int *data)
 
int getenv_long (const char *name, long *data)
 
int getenv_ulong (const char *name, unsigned long *data)
 
int getenv_quad (const char *name, quad_t *data)
 
void tunable_int_init (void *data)
 
void tunable_long_init (void *data)
 
void tunable_ulong_init (void *data)
 
void tunable_quad_init (void *data)
 
void tunable_str_init (void *data)
 

Variables

char * kern_envp
 
static int env_len
 
static int env_pos
 
char ** kenvp
 
struct mtx kenv_lock
 
int dynamic_kenv = 0
 

Macro Definition Documentation

#define KENV_CHECK
Value:
if (!dynamic_kenv) \
panic("%s: called before SI_SUB_KMEM", __func__)
int dynamic_kenv

Definition at line 76 of file kern_environment.c.

Referenced by setenv(), and unsetenv().

#define KENV_SIZE   512 /* Maximum number of environment strings */

Definition at line 59 of file kern_environment.c.

Referenced by init_dynamic_kenv(), setenv(), and sys_kenv().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static char* _getenv_dynamic ( const char *  name,
int *  idx 
)
static

Definition at line 268 of file kern_environment.c.

References kenv_lock, and kenvp.

Referenced by getenv(), setenv(), testenv(), and unsetenv().

Here is the caller graph for this function:

static char* _getenv_static ( const char *  name)
static

Definition at line 287 of file kern_environment.c.

References kern_envp, and kernenv_next().

Referenced by getenv(), and testenv().

Here is the call graph for this function:

Here is the caller graph for this function:

void freeenv ( char *  env)

Definition at line 257 of file kern_environment.c.

References dynamic_kenv, and free().

Referenced by detect_virtual(), getenv_quad(), getenv_string(), parse_dir_ask_printenv(), start_init(), sys_kenv(), and vfs_mountroot_conf0().

Here is the call graph for this function:

Here is the caller graph for this function:

char* getenv ( const char *  name)

Definition at line 312 of file kern_environment.c.

References _getenv_dynamic(), _getenv_static(), buf, dynamic_kenv, kenv_lock, and malloc().

Referenced by detect_virtual(), getenv_quad(), getenv_string(), parse_dir_ask_printenv(), start_init(), sys_kenv(), and vfs_mountroot_conf0().

Here is the call graph for this function:

Here is the caller graph for this function:

int getenv_int ( const char *  name,
int *  data 
)

Definition at line 473 of file kern_environment.c.

References getenv_quad().

Here is the call graph for this function:

int getenv_long ( const char *  name,
long *  data 
)

Definition at line 503 of file kern_environment.c.

References getenv_quad().

Here is the call graph for this function:

int getenv_quad ( const char *  name,
quad_t *  data 
)

Definition at line 533 of file kern_environment.c.

References freeenv(), getenv(), and value.

Referenced by getenv_int(), getenv_long(), getenv_uint(), and getenv_ulong().

Here is the call graph for this function:

Here is the caller graph for this function:

int getenv_string ( const char *  name,
char *  data,
int  size 
)

Definition at line 456 of file kern_environment.c.

References freeenv(), and getenv().

Here is the call graph for this function:

int getenv_uint ( const char *  name,
unsigned int *  data 
)

Definition at line 488 of file kern_environment.c.

References getenv_quad().

Here is the call graph for this function:

int getenv_ulong ( const char *  name,
unsigned long *  data 
)

Definition at line 518 of file kern_environment.c.

References getenv_quad().

Here is the call graph for this function:

static void init_dynamic_kenv ( void *data  __unused)
static

Definition at line 225 of file kern_environment.c.

References dynamic_kenv, kenv_lock, KENV_SIZE, kenvp, kern_envp, kernenv_next(), malloc(), mtx_init(), and printf().

Here is the call graph for this function:

void init_static_kenv ( char *  buf,
size_t  len 
)

Definition at line 214 of file kern_environment.c.

References buf, env_len, env_pos, and kern_envp.

static char * kernenv_next ( char *  cp)
static

Definition at line 572 of file kern_environment.c.

Referenced by _getenv_static(), and init_dynamic_kenv().

Here is the caller graph for this function:

static MALLOC_DEFINE ( M_KENV  ,
"kenv"  ,
"kernel environment"   
)
static
int setenv ( const char *  name,
const char *  value 
)

Definition at line 381 of file kern_environment.c.

References _getenv_dynamic(), buf, dynamic_kenv, env_len, free(), KENV_CHECK, kenv_lock, KENV_SIZE, kenvp, malloc(), setenv_static(), and sprintf().

Referenced by sys_kenv().

Here is the call graph for this function:

Here is the caller graph for this function:

static int setenv_static ( const char *  name,
const char *  value 
)
static

Definition at line 358 of file kern_environment.c.

References env_len, env_pos, kern_envp, and sprintf().

Referenced by setenv().

Here is the call graph for this function:

Here is the caller graph for this function:

int sys_kenv ( struct thread *  td,
struct kenv_args *  uap 
)

Definition at line 80 of file kern_environment.c.

References dynamic_kenv, free(), freeenv(), getenv(), kenv_lock, KENV_SIZE, kenvp, malloc(), name, priv_check(), setenv(), unsetenv(), and value.

Here is the call graph for this function:

SYSINIT ( kenv  ,
SI_SUB_KMEM  ,
SI_ORDER_ANY  ,
init_dynamic_kenv  ,
NULL   
)
int testenv ( const char *  name)

Definition at line 342 of file kern_environment.c.

References _getenv_dynamic(), _getenv_static(), dynamic_kenv, and kenv_lock.

Here is the call graph for this function:

void tunable_int_init ( void *  data)

Definition at line 586 of file kern_environment.c.

void tunable_long_init ( void *  data)

Definition at line 594 of file kern_environment.c.

void tunable_quad_init ( void *  data)

Definition at line 610 of file kern_environment.c.

void tunable_str_init ( void *  data)

Definition at line 618 of file kern_environment.c.

void tunable_ulong_init ( void *  data)

Definition at line 602 of file kern_environment.c.

int unsetenv ( const char *  name)

Definition at line 430 of file kern_environment.c.

References _getenv_dynamic(), free(), KENV_CHECK, kenv_lock, and kenvp.

Referenced by sys_kenv().

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

int dynamic_kenv = 0

Definition at line 74 of file kern_environment.c.

Referenced by freeenv(), getenv(), init_dynamic_kenv(), res_find(), setenv(), sys_kenv(), and testenv().

int env_len
static

Definition at line 63 of file kern_environment.c.

Referenced by init_static_kenv(), setenv(), and setenv_static().

int env_pos
static

Definition at line 64 of file kern_environment.c.

Referenced by init_static_kenv(), and setenv_static().

struct mtx kenv_lock
char** kenvp
char* kern_envp