Subject: RE: Querying an userland program from the kernel
To: Matthias Scheler <tech-kern@NetBSD.org>
From: Gordon Waidhofer <gww@traakan.com>
List: tech-kern
Date: 01/24/2004 19:45:29
A generalized "upcall" mechanism whereby the
kernel can get help from userland programs
would be very nice for a whole pile of problems.

A mechanism like divert(4) (also see natd(8)) on
FreeBSD makes the most sense to me. Seems like
there was something to do with routing that
similarly used sockets to communicate between
the kernel and userland, but I can't find it
right now.

Divert(4) may seem a little specialized. Yet,
using sockets for kernel/userland messages
makes a lot of sense. If the userland peer is
missing, the kernel fails the request itself.
If the userland peer is slow to respond (times
out), again the kernel can take action.

Parallelism and overlapping requests are easier.
For example, a userland automount support daemon
can use select(2) to await requests from the kernel
and also responses from NIS (or LDAP, etc, etc).
If one requests takes several seconds dozens of
other requests can be satisfied.

Upcalls would be way cool.

I look forward to your future posts.

Regards,
	-gww

> -----Original Message-----
> From: tech-kern-owner@NetBSD.org [mailto:tech-kern-owner@NetBSD.org]On
> Behalf Of Matthias Scheler
> Sent: Saturday, January 24, 2004 6:39 PM
> To: tech-kern@NetBSD.org
> Subject: Querying an userland program from the kernel
> 
> 
> 	Hello,
> 
> I'm thinking about writing a better automounter for NetBSD (which above
> all doesn't use softlinks but direct mounts). One of the conceptual
> problems is getting the parameters for a mount (e.g. remote machine
> and filesystem name for an NFS mount) from the kernel. Preloading the
> automount table would possible but clumsy(*). I'm therefore searching
> for a method to query an userland program from the kernel synchronously.
> Is there already an example somewhere in NetBSD's kernel sources? If not
> does anybody have an idea how to do this?
> 
> 	Kind regards
> 
> (*) IIUC the startup scripts of Red Hat/SuSE correctly Linux's autofs
>     needs to know all mount parameters in advance. So in case of NIS they
>     fetch the whole map with "ypcat" and preload it. As a result automouter
>     map changes need manual reload to get effective.
> 
> -- 
> Matthias Scheler                                  http://scheler.de/~matthias/