Subject: kernel symbol tables (was Re: vmstat, iostat etc no longer work?)
To: None <current-users@NetBSD.ORG>
From: Mike Long <mike.long@analog.com>
List: current-users
Date: 11/12/1996 14:36:27
>Date: Tue, 12 Nov 1996 15:49:43 +0100
>From: ws@kurt.tools.de (Wolfgang Solfrank)
>
>> It's possible in some ports (such as the alpha) to get the name of
>> the loaded kernel. In others, such as the i386, it may be possible
>> for the boot loader to pass this on to the kernel. Why not have a
>> new sysctl variable, kern.filename or whatever, that contains the
>> filename that the kernel was loaded from?
>
>Note that there are situations where the device the kernel came from isn't
>available to the kernel.  Like booting from floppy and switching disks after
>loading the kernel.  Or booting the kernel from a device the kernel doesn't
>have a driver for.

In fact, there's no guarantee that the filesystem the kernel is loaded
from is the root after boot, either.  So passing in "/netbsd" (even if
that's the name the user gave) is NFG; you need to pass in something
like (on the i386) "sd(0,a)/netbsd".  The kern.filename sysctl()
hander has to interpret the device spec and match it up with a mounted
filesystem, and can return a null string if that's not possible.
Better yet, the sysctl can return the raw data, and userland code
can try to match it up with a filesystem.

Once that problem is solved, Wolfgang's proposal is no worse than
what we're stuck with already.

OK; so far, we have two potential solutions:

1) Use kernel symbol table in memory.
   PROS: guaranteed to be correct, can include LKM symbols
   CONS: kernel bloat, bad for low-memory machines (sun3)

2) Maintain pointer to kernel on disk
   PROS: minimal kernel memory impact
   CONS: kernel image may be unavailable after boot, and may have been
         moved.
-- 
Mike Long <mike.long@analog.com>     <URL:http://www.shore.net/~mikel>
VLSI Design Engineer         finger mikel@shore.net for PGP public key
Analog Devices, CPD Division          CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA       (eq (opinion 'ADI) (opinion 'mike)) -> nil