Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 09 Nov 2003 16:34:49 -0000
From:      "Reinier Kleipool" <Reinier@Kleipool.org>
To:        <freebsd-hackers@freebsd.org>
Subject:   kernel enviroment in sysctl MIB
Message-ID:  <000001c3a6df$60ef28f0$5201a8c0@ovs.kleipool.org>

next in thread | raw e-mail | index | archive | help
Hello,

  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@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,
Reinier Kleipool,
Network Engineer,
Protocomix
Rotterdamserijweg 122
3042 AS Rotterdam
Tel 0654 227144
Fax 010 245 0902
Reinier@protocomix.nl




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?000001c3a6df$60ef28f0$5201a8c0>