Writing portable code that reads /dev/kmem

Curtis Yarvin cgy at cs.brown.edu
Fri May 24 00:20:56 AEST 1991


In article <BLARSEN.91May23060050 at spider.uio.no> Bjorn.Larsen at usit.uio.no writes:
>
>We are writing a daemon that should execute on a number of different
>UNIX platforms. It should fetch performance information about the
>running system.
>
>We want to make this program as portable as possible, possibly by
>dividing it into one generic part and one system-specific part.
>
>The UNIX variants that we want to run this daemon on includes SunOS,
>Ultrix, OSF/1, SVR4, SVR3.2, Convex UNIX, SCO UNIX, and possibly
>others.

Yow.

>I'm looking for advice on the best way to handle this. Does there
>exist a standard interface for retreiving such information?
>I've heard rumors that there exists a kmem-access library for BSD4.3.

It should never have had to exist in the first place; but there is.  -lkvm
will link with it.  But it needs a symbol to find.  It can read the data
corresponding to a kernel name or a kernel virtual address.  But bear in
mind that when we say "symbol," we're talking about internal kernel
variables.  This stuff is by definition unportable.

Your best bet is to make a very explicit split between the portable and
nonportable modules of the monitor daemon.

Curtis



More information about the Comp.unix.wizards mailing list