Skip to content

Commit

Permalink
libusb0: implement is_kernel_driver_active() for Mac OS
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jonasmalacofilho committed Jun 30, 2021
1 parent 5d7cb25 commit f0c513c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions usb/backend/libusb0.py
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,17 @@ def is_kernel_driver_active(self, dev_handle, intf):
if err.backend_error_code == -errno.ENODATA:
return False
raise
elif sys.platform == 'darwin':
# on mac os/darwin we assume all users are running libusb-compat,
# which, in turn, uses libusb_kernel_driver_active()
try:
driver_name = self.__get_driver_name(dev_handle, intf)
return True
except USBError as err:
# ENODATA means that no kernel driver is attached
if err.backend_error_code == -errno.ENODATA:
return False
raise
elif sys.platform.startswith('freebsd') or sys.platform.startswith('dragonfly'):
# this is similar to the Linux implementation, but the generic
# driver is called 'ugen' and usb_get_driver_np() simply returns an
Expand Down

0 comments on commit f0c513c

Please sign in to comment.