How to check if kernel driver is attached with libusb-0.1? -
in libusb-1.0 1 can use libusb_kernel_driver_active
this:
if (libusb_kernel_driver_active(dev_handle, 0) == 1) { //find out if kernel driver attached cout<<"kernel driver active"<<endl; if(libusb_detach_kernel_driver(dev_handle, 0) == 0) //detach cout<<"kernel driver detached!"<<endl; }
how check using libusb-0.1?
for libusb-compat can use usb_get_driver_np
:
api_exported int usb_get_driver_np(usb_dev_handle *dev, int interface, char *name, unsigned int namelen) { int r = libusb_kernel_driver_active(dev->handle, interface); if (r == 1) { /* libusb-1.0 doesn't expose driver name, fill in dummy value */ snprintf(name, namelen, "dummy"); return 0; } else if (r == 0) { return -(errno=enodata); } else { return compat_err(r); } }
Comments
Post a Comment