Subject: Re: Getting the device tree
To: None <lennart@augustsson.net, tech-kern@netbsd.org>
From: Noriyuki Soda <soda@sra.co.jp>
List: tech-kern
Date: 01/02/2001 22:23:34
> I'd like to add a sysctl to get all the devices in the kernel.
It seems to be better to use a pseudo device rather than sysctl
to achieve this. Because...
> Why do I want this? Well, I'm messing with USB (as usual :). Right
> now I can get a message (by using the USB event mechanism) when
> a USB device is connected. Say that I connect some speakers, I will
> get a message that, say, "uaudio2" has been connected. But which
> audio device does this correspond to? There is no way to find out
> except by getting the device tree.
If you use sysctl, you have to use busy wait to detect a change
of device configuration.
If there is a pseudo device which reports attaching/detaching event
on its read(2) entry, you can use standard read(2)/poll/(2)/select(2)
interface to wait the change.
--
soda