LibusbDevice: Don't detach kernel drivers on macOS

This commit is contained in:
Sanjay Govind
2025-01-31 20:25:50 +13:00
parent cd3993708f
commit 10e044872d
2 changed files with 5 additions and 1 deletions

View File

@ -439,6 +439,9 @@ static int DoForEachInterface(const Configs& configs, u8 config_num, Function ac
int LibusbDevice::ClaimAllInterfaces(u8 config_num) const int LibusbDevice::ClaimAllInterfaces(u8 config_num) const
{ {
const int ret = DoForEachInterface(m_config_descriptors, config_num, [this](u8 i) { const int ret = DoForEachInterface(m_config_descriptors, config_num, [this](u8 i) {
// On macos detaching would fail without root or entitlement.
// We assume user is using GCAdapterDriver and therefore don't want to detach anything
#if !defined(__APPLE__)
const int ret2 = libusb_detach_kernel_driver(m_handle, i); const int ret2 = libusb_detach_kernel_driver(m_handle, i);
if (ret2 < LIBUSB_SUCCESS && ret2 != LIBUSB_ERROR_NOT_FOUND && if (ret2 < LIBUSB_SUCCESS && ret2 != LIBUSB_ERROR_NOT_FOUND &&
ret2 != LIBUSB_ERROR_NOT_SUPPORTED) ret2 != LIBUSB_ERROR_NOT_SUPPORTED)
@ -447,6 +450,7 @@ int LibusbDevice::ClaimAllInterfaces(u8 config_num) const
LibusbUtils::ErrorWrap(ret2)); LibusbUtils::ErrorWrap(ret2));
return ret2; return ret2;
} }
#endif
return libusb_claim_interface(m_handle, i); return libusb_claim_interface(m_handle, i);
}); });
if (ret < LIBUSB_SUCCESS) if (ret < LIBUSB_SUCCESS)

View File

@ -584,7 +584,7 @@ static bool CheckDeviceAccess(libusb_device* device)
if (ret == 1) // 1: kernel driver is active if (ret == 1) // 1: kernel driver is active
{ {
// On macos detaching would fail without root or entitlement. // On macos detaching would fail without root or entitlement.
// We assume user is using GCAdapterDriver and therefor don't want to detach anything // We assume user is using GCAdapterDriver and therefore don't want to detach anything
#if !defined(__APPLE__) #if !defined(__APPLE__)
ret = libusb_detach_kernel_driver(s_handle, 0); ret = libusb_detach_kernel_driver(s_handle, 0);
detach_failed = detach_failed =