Subject: Re: Querying an userland program from the kernel
To: Matthias Scheler <>
From: Stephan Uphoff <>
List: tech-kern
Date: 01/24/2004 22:06:07

the usual solution is for the userland program to use a
system call (example ioctl) to sleep in the kernel waiting for
a query from the kernel.
A query from the kernel unblocks the process (lwp) and the query
is copied into userspace.
The system call returns and the userland program can compute the
answer to the query.
The userland can then issue another system call (ioctl) that copies
the answer into the kernel, wakes up the lwp waiting for the answer
and then waits for the next query.

The system call should sleep with P_CATCH to allow the killing of
the userland program.


> 	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