Subject: Getting file descriptor in driver ioctl method
To: None <>
From: Emmanuel Dreyfus <>
List: tech-kern
Date: 05/04/2002 11:28:26
Hi all

For IRIX binary compatibility, I need to implement a device driver that
IRIX libc uses to provide atomic operation on semaphores, and blocking
on semaphore using the select system call.

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?

Emmanuel Dreyfus.
Ibhf irarm qr creqer ibger grzcf n qrpbqre har fvtangher fnaf vagrerg.