How to access the values of the kenv variables in driver code?

Oliver Fromme olli at lurza.secnetix.de
Tue Sep 19 03:55:37 PDT 2006


sivakumar.subramani at wipro.com wrote:
 > I would like to have some of the configuration parameters of my driver
 > to be present as part of the /boot/device.hints file. After adding a
 > variable I could see that variable and it's value as part of kevn's
 > ouput.
 > 
 > Can any one please let me know how to access the value of these
 > variables in my drive code?

>From sys/kern/kern_environment.c:

/*
 * The unified bootloader passes us a pointer to a preserved copy of
 * bootstrap/kernel environment variables.  We convert them to a
 * dynamic array of strings later when the VM subsystem is up.
 *
 * We make these available through the kenv(2) syscall for userland
 * and through getenv()/freeenv() setenv() unsetenv() testenv() for
 * the kernel.
 */

The following shell command will give you lots of examples:

find /usr/src/sys -name "*.c" | xargs grep -w getenv

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd
Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.

C++: "an octopus made by nailing extra legs onto a dog"
        -- Steve Taylor, 1998


More information about the freebsd-net mailing list