Subject: Re: Getting file descriptor in driver ioctl method
To: Emmanuel Dreyfus <>
From: Aaro J Koskinen <>
List: tech-kern
Date: 05/06/2002 12:11:57

On Sat, 4 May 2002, Emmanuel Dreyfus wrote:
> Here is roughly how it works:
> 1- libc sets up a semaphore
> 2- it opens /dev/usemaclone and gets a file descriptor fd
> 3- it does an ioctl on fd to register the semaphore structure address in
> user land.
> 4- then for instance, it does another ioctl on fd (with no other
> argument) to get -1 if the semaphore value is < 0, or 0 if it is >= 0.
> Obviously, the IRIX kernel is able to find the semaphore structure
> adress given the file descriptor. In a normal ioctl method on NetBSD, it
> does not seems I have access to the file descriptor or the vnode on
> which the operation is done. Is there any way of getting it?
> For now the only solution I see is to have a special handling in
> irix_sys_ioctl for /dev/usemaclone ioctls and directly call a
> nonstandard ioctl method without going through the standard sys_ioctl
> nor cdevsw[major].d_ioctl way. Is there another solution?

File system ioctl can naturally access the vnode (you won't probably
need or even want to know what the file descriptor is). Maybe you
should implement the "device" as a special file in the /kern file
system, instead of writing a device driver (and then use symlink
/dev/usemaclone -> /kern/usemaclone).


Aaro Koskinen
E-mail:            "I'm the ocean, I'm the giant undertow."