Subject: kqueue and plug&play notifications
To: None <>
From: Pat Laplante <>
List: current-users
Date: 11/02/2004 11:27:36
I am trying to do is to add plug and play support to my custom hardware 
(running NetBSD on evbarm). I have a sd slot (with a driver that we 
wrote) and usb host connecter to allow people to plug usb devices like 
card readers and so on.  Right now, I am designing it this way: 1 
process that will listen using select on /dev/usb and /dev/sdi.  When a 
plug or unplug occurs, The process must notify listeners (who ever 
cares) that such event happened.

What is the best way to achieve this:
    1) Should it be a pseudo kernel driver? (providing support for kqueue)
    2) Should it be a userland process that people registered with using 
socket for example?

I read in this post: that there 
are plans to add notification in the kernel.  What is the status of 
that?  Should I pursue this approach and implement something similar?  
If this is the right approach but nobody has the time to tackle the 
issue, I would be more than happy to work on that and then provide that 
mechanism to you guys.

"There are some plans to add glue for notification of e.g. USB
devices additions/removals to userland or to support e.g. ifwatchd
functionality better way in future. The code is extensible
well and any additional filters like that are easy to add."

Also, about kqueue, I have a couple of questions

1) Will it support except signal (just like select does)?
2) Can I register for event for a device node from 2 processes?  I tried 
that with /dev/usb and
    a) I can only open /dev/usb once
    b) kevent always return a signal on the EVT_READ when there is 
nothing to read.