Albert Lee wrote:
On Wed, 14 Oct 2009 11:14:47 -0700, Peter Memishian
<peter.memish...@sun.com> wrote:
how do I get notifications when hardware (e.g. USB devices) is
> hotplugged from a C/C++ application? On Linux, I can listen for those
> events on a socket(PF_NETLINK, SOCK_DGRAM, NETLINK_KOBJECT_UEVENT) --
> there's probably something similar in OpenSolaris?
Will the rcmscript(4) mechanism do what you need?
A higher-level API for device detection and hotplug notification is
provided by HAL, see http://opensolaris.org/os/project/tamarack/hal_re.html
for details. There should also be various guides online. As a bonus, the
API is also available on some other OSes including FreeBSD and Linux. There
is some concern about lack of maintainership in the implementation but it
is currently still the standard.
Two things to keep in mind:
1. HAL on Solaris currently does not support all device classes that the
kernel supports. In particular, it does not support networking: there've
been some discussions about that, mostly around the fact that HAL's
model was not rich enough to represent Solaris networking in all its
glory, and that representing a subset was not an option.
2. HAL is no longer in active development. The replacement will be
DeviceKit and its subsystems.
There are several options on Solaris, depending on what you're trying to
accomplish. Study the source. libdevinfo(3LIB) is tightly coupled with
the kernel device framework and works well in many cases (HAL is based
on it). RCM works well for certain cases. The new hotplug architecture
(PSARC/2008/181) has promise, though the current implementation is
limited. For USB, I would recommend libusb: it works on many OSes and on
SunRay.
-Artem
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code