MCPcopy Create free account
hub / github.com/F-Stack/f-stack / kern_getenv

Function kern_getenv

freebsd/kern/kern_environment.c:480–502  ·  view source on GitHub ↗

* Look up an environment variable by name. * Return a pointer to the string if found. * The pointer has to be freed with freeenv() * after use. */

Source from the content-addressed store, hash-verified

478 * after use.
479 */
480char *
481kern_getenv(const char *name)
482{
483 char *cp, *ret;
484 int len;
485
486 if (dynamic_kenv) {
487 len = KENV_MNAMELEN + 1 + kenv_mvallen + 1;
488 ret = uma_zalloc(kenv_zone, M_WAITOK | M_ZERO);
489 mtx_lock(&kenv_lock);
490 cp = _getenv_dynamic(name, NULL);
491 if (cp != NULL)
492 strlcpy(ret, cp, len);
493 mtx_unlock(&kenv_lock);
494 if (cp == NULL) {
495 uma_zfree(kenv_zone, ret);
496 ret = NULL;
497 }
498 } else
499 ret = _getenv_static(name);
500
501 return (ret);
502}
503
504/*
505 * Test if an environment variable is defined.

Callers 15

sys_kenvFunction · 0.70
getenv_boolFunction · 0.70
parse_dir_ask_printenvFunction · 0.70
vfs_mountroot_conf0Function · 0.70
start_initFunction · 0.70
parse_manifest_eventFunction · 0.50
netdump_modeventFunction · 0.50
cpu_startupFunction · 0.50
bios32_initFunction · 0.50
jz4780_efuse_update_kenvFunction · 0.50

Calls 7

mtx_lockFunction · 0.70
_getenv_dynamicFunction · 0.70
mtx_unlockFunction · 0.70
_getenv_staticFunction · 0.70
uma_zallocFunction · 0.50
strlcpyFunction · 0.50
uma_zfreeFunction · 0.50

Tested by

no test coverage detected