Many different hotplug events can occur for the "usb" subsystem
(e.g. attaching/detaching a class driver), but libusb only needs
to care about events where the device type is "usb_device". All
other events cause needless attempts to lookup the device address,
which will fail as the paths for such events do not correspond to
actual USB device nodes.
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
return -1;
}
+ /* check that this is an actual usb device */
+ tmp = netlink_message_parse(buffer, len, "DEVTYPE");
+ if (NULL == tmp || 0 != strcmp(tmp, "usb_device")) {
+ /* not usb. ignore */
+ return -1;
+ }
+
tmp = netlink_message_parse(buffer, len, "BUSNUM");
if (NULL == tmp) {
/* no bus number. try "DEVICE" */
goto err_free_ctx;
}
- r = udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "usb", 0);
+ r = udev_monitor_filter_add_match_subsystem_devtype(udev_monitor, "usb", "usb_device");
if (r) {
usbi_err(NULL, "could not initialize udev monitor filter for \"usb\" subsystem");
goto err_free_monitor;
}
udev_enumerate_add_match_subsystem(enumerator, "usb");
+ udev_enumerate_add_match_property(enumerator, "DEVTYPE", "usb_device");
udev_enumerate_scan_devices(enumerator);
devices = udev_enumerate_get_list_entry(enumerator);
-#define LIBUSB_NANO 11007
+#define LIBUSB_NANO 11008