[pull] master from libusb:master#10
Merged
pull[bot] merged 6 commits intohttpsgithu:masterfrom May 17, 2021
Merged
Conversation
USBDeviceReEnumerate() does not return an error code (bug?) so if it fails we could be stuck waiting forever. Set a sane timeout to 10s. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Since it calls USBDeviceReEnumerate() and not USBDeviceReset(), we name it accordingly. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
When libusb_detach_kernel_driver() is called on the first interface, we use the capture re-enumerate APIs to force kernel drivers to detach. On subsequent calls, a counter is incremented to keep track of the number of detach calls. When libusb_attach_kernel_driver() is called for the same number of times, then we re-enumerate (reset) and let kernel drivers re-attach. darwin_kernel_driver_active() is changed to attempt to claim an interface and return 1 only if a kIOReturnExclusiveAccess status is returned. The old implementation which looks for a CFBundleID in the IORegistryEntry does not seem to work in all cases. darwin_reset_device() is aware of the capture status and will re-set twice if capture mode is enabled: once to do a USB reset and again to re-capture. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
To use USBDeviceReEnumerate with kUSBReEnumerateCaptureDeviceMask your app either needs to be running as root OR have the 'com.apple.vm.device-access' entitlement AND have the user authorization requested via IOServiceAuthorize(). We can use the capture re-enumerate APIs if either 1) the process is running as root or 2) the 'com.apple.vm.device-access' entitlement is used AND IOServiceAuthorize() is called. We assume that if the entitlement is not there then we are running as root--if this is not true, then darwin_detach_kernel_driver will fail anyways. The authorization status is cached in the device's start() so we have to stop() and start() the device by destroying the plugin and recreating it again. Signed-off-by: Nathan Hjelm <hjelmn@google.com>
The InterfaceVersion is what we want and there is no reason to also check that the InterfaceVersion matches the macOS version it was introduced in. This check inadvertently disables features for other Apple platforms that use IOKit. Closes #911 Signed-off-by: Nathan Hjelm <hjelmn@google.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot]
Can you help keep this open source service alive? 💖 Please sponsor : )