Re: kernel enviroment in sysctl MIB
On Sunday 09 November 2003 10:34 am, Reinier Kleipool wrote: > 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. I've been using the 'kenv' program for some time to do this. For my purposes it seems to work quite well (have loader display a menu with an option of whether or not to start X after bootup). It seems to do the trick for me -- if you need it from a program rather than a shell script you may want to look at the source for kenv(1) to see how it gets its information. Craig ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
kernel enviroment in sysctl MIB
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 [EMAIL PROTECTED], 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 [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
RE: kernel enviroment in sysctl MIB
Perter Pentechv wrote > Take a look at the kenv(1) utility - its source is in the > src/usr.bin/kenv/kenv.c file. Yes this does the job. But in a strange way... It starts at OID 0.3 (kern.environment) and appends small integers to it (0,1,2,3 etc). Why do it so strange.. Why are the variable names not just visible in sysctl. I know that the kern enviroment is not often used in normal operation, but would't it be nicer to just see the variables in the sysctl mib? I can incorporate this "trick" in my install program, but I could also try to patch kern_environment.c so the variables become visible. What do you think Kind regards, Reinier ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"
Re: kernel enviroment in sysctl MIB
On Wed, Nov 12, 2003 at 05:00:54PM +0200, Peter Pentchev wrote: > On Tue, Nov 11, 2003 at 06:01:55PM +0100, Reinier Kleipool wrote: > > 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. > [snip] > > 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. > > Take a look at the kenv(1) utility - its source is in the > src/usr.bin/kenv/kenv.c file. Errr, of course, if you're working with FreeBSD 5.x after 2003/01/20, that would be src/bin/kenv/kenv.c :) G'luck, Peter -- Peter Pentchev [EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 Nostalgia ain't what it used to be. pgp0.pgp Description: PGP signature
Re: kernel enviroment in sysctl MIB
On Tue, Nov 11, 2003 at 06:01:55PM +0100, Reinier Kleipool wrote: > 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. [snip] > 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. Take a look at the kenv(1) utility - its source is in the src/usr.bin/kenv/kenv.c file. There is a weird comment at line 74, where the kern.environment sysctl is accessed in a really 'magic & undocumented' way. Look at what it does - basically enumerating oid's from a given starting point, the starting point being obtained in said 'magic & undocumented' way - and see if you could use the same approach. Alternatively, you could just invoke kenv(1) with your variables as command-line parameters from your program/script, although this might incur a performance cost. G'luck, Peter -- Peter Pentchev [EMAIL PROTECTED][EMAIL PROTECTED][EMAIL PROTECTED] PGP key:http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 .siht ekil ti gnidaer eb d'uoy ,werbeH ni erew ecnetnes siht fI pgp0.pgp Description: PGP signature
kernel enviroment in sysctl MIB
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 [EMAIL PROTECTED], 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 [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"