From owner-freebsd-hackers@FreeBSD.ORG Tue Nov 11 09:04:25 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1F85216A4D0 for ; Tue, 11 Nov 2003 09:04:25 -0800 (PST) Received: from amsfep13-int.chello.nl (amsfep13-int.chello.nl [213.46.243.24]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7A0F143F93 for ; Tue, 11 Nov 2003 09:04:20 -0800 (PST) (envelope-from Reinier@Kleipool.org) Received: from titan.kleipool.org ([213.93.137.166]) by amsfep13-int.chello.nlESMTP <20031111170158.FVA1451.amsfep13-int.chello.nl@titan.kleipool.org> for ; Tue, 11 Nov 2003 18:01:58 +0100 Received: from io (io.ovs.kleipool.org [192.168.1.82]) by titan.kleipool.org (8.12.6/8.12.6) with SMTP id hABH1unk070685 for ; Tue, 11 Nov 2003 18:01:57 +0100 (CET) (envelope-from Reinier@Kleipool.org) From: "Reinier Kleipool" To: Date: Tue, 11 Nov 2003 18:01:55 +0100 Message-ID: <001701c3a875$836b1960$5201a8c0@ovs.kleipool.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook CWS, Build 9.0.2416 (9.0.2911.0) X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4925.2800 Importance: Normal Subject: kernel enviroment in sysctl MIB X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Nov 2003 17:04:25 -0000 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