Subject: Getting the device tree
To: None <tech-kern@netbsd.org>
From: Lennart Augustsson <lennart@augustsson.net>
List: tech-kern
Date: 12/30/2000 14:38:25
I'd like to add a sysctl to get all the devices in the kernel.
Yes, this can be done by digging around in the kernel data
structures, but this has two problems: you need root permissions
to do it and it's not atomic (atomicity can be a problem since device
can come and go while accessing the kernel data structures).

What I propose is a sysctl that just copies the list alldevs into a
user space buffer.  The userland code can recover the information
from that.

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.

Opinions?

--

        -- Lennart