kernel enviroment in sysctl MIB
Reinier at Kleipool.org
Sun Nov 9 08:34:49 PST 2003
I am investigating the possiblilies for looking at the kernel boot
parameters from within a userland utility. (Possibly a new FreeBSD install
facility) The idea is that by looking at sysctl kern.environment.* you
should be able to see the BTX variables. An install program could use this
to see an INSTALL_SERVER=install.company.com variable (etc...) to use as
install server. The BTX loader could provide these variables at install boot
time, thus enableing fully automated installs.
When I look at kern/kern_environment.c I see that the BTX loader provides
its "environment variables" to the kernel. They show up in the kernel under
char *kern_envp. When looking at this variable in the gdb debugger I see the
first environment variable of the BTX loader: "LINES=24". I do not master
the gdb enhough to see the next enviroment variable (I tried (kgdb) print
kern_envp at 2, but this does not show the variable after the first \0
character) but I am sure its there.
My question is this: When looking at kern/kern_environmet.c I see routines
that install a SYSCTL_NODE kern.environment. The sysctl_kernenv routine
handles this node. What I do not understand is how the environment is
returned from this routine.
I suppose that at sys_init time you should traverse the environment once and
install SYSCTL_ADD_STRING leaves for all environment variables. Then later
sysctl calls could ask for the value of these strings.
Am I right? Or does it work differently?
When you issue the command "sysctl kern.environment" as root you see no
output, but also no error! When you try "sysctl kern.environment.LINES" you
do get an error I can understand why! No leaves were installed.
What is wrong, and how can we fix it?
Vriendelijke groet / Kind Regards,
3042 AS Rotterdam
Tel 0654 227144
Fax 010 245 0902
Reinier at protocomix.nl
More information about the freebsd-hackers