Subject: Re: Newbie questions
To: None <prlw1@cam.ac.uk>
From: Bill Studenmund <wrstuden@zembu.com>
List: tech-kern
Date: 01/22/2001 11:24:29
On Mon, 22 Jan 2001, Patrick Welche wrote:

> I'm trying to get the kernel to fill in a SIMPLEQ, and reach it from userland
> via an ioctl.
> 
> - Is there something simpler than a SIMPLEQ? (new to sys/queue.h)

LISTs I think. But all of the QUEUE macros are as easy to use as any
other. The deciding factor should be the insertion & removal needs.

> - Shouldn't I need a copyout or something? Don't see where though..

No. NetBSD's ioctl syscall system does that for you. You will be handed
a pointer to memory in the kernel. If you have an ioctl which is an _IOR,
_IOW, or _IOWR, then you get a memory structure which is as big as the
struct you're passing around. If the ioctl is an _IO ioctl, then you have
a pointer to a caddr_t.

When you return, if you have an _IOW or _IOWR ioctl, the data in the
memory buffer your routine was passed are copied back out to userland.

> Test userland prog works. With same function filling queue in kernel, I just
> get back null pointer, then again it doesn't surprise me too much, as I put
> a SIMPLEQ_HEAD in a header file, but what does a "global" variable mean when
> it appears in both kernel and executable - not very global anymore...

?? The kernel and your userland program are different programs, so they
have different concepts of "global" variables.

I assume since your kernel isn't crashing, that somewhere you are
initilaizing the SIMPLES_HEAD instance you have.

How does your ioctl routine know which element on the list to return?

Take care,

Bill