1

在 libusb-1.0 中可以使用libusb_kernel_driver_active

if (libusb_kernel_driver_active(dev_handle, 0) == 1) { //find out if kernel driver is attached
        cout<<"Kernel Driver Active"<<endl;
        if(libusb_detach_kernel_driver(dev_handle, 0) == 0) //detach it
            cout<<"Kernel Driver Detached!"<<endl;
    }

如何使用 libusb-0.1 进行检查?

4

1 回答 1

0

对于 libusb-compat,您可以使用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, so fill in a dummy value */
        snprintf(name, namelen, "dummy");
        return 0;
    } else if (r == 0) {
        return -(errno=ENODATA);
    } else {
        return compat_err(r);
    }
}
于 2013-07-31T12:47:26.507 回答