Skip to content

Commit f0c513c

Browse files
libusb0: implement is_kernel_driver_active() for Mac OS
Assumes the libusb0 implementation in use is libusb-compat, and depends on libusb_kernel_driver_active() support for that platform (expected in libusb 1.0.25). Fixes: #374
1 parent 5d7cb25 commit f0c513c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

usb/backend/libusb0.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,17 @@ def is_kernel_driver_active(self, dev_handle, intf):
634634
if err.backend_error_code == -errno.ENODATA:
635635
return False
636636
raise
637+
elif sys.platform == 'darwin':
638+
# on mac os/darwin we assume all users are running libusb-compat,
639+
# which, in turn, uses libusb_kernel_driver_active()
640+
try:
641+
driver_name = self.__get_driver_name(dev_handle, intf)
642+
return True
643+
except USBError as err:
644+
# ENODATA means that no kernel driver is attached
645+
if err.backend_error_code == -errno.ENODATA:
646+
return False
647+
raise
637648
elif sys.platform.startswith('freebsd') or sys.platform.startswith('dragonfly'):
638649
# this is similar to the Linux implementation, but the generic
639650
# driver is called 'ugen' and usb_get_driver_np() simply returns an

0 commit comments

Comments
 (0)