| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
|
|
|
| |
This macro was replaced by AS_HELP_STRING. This commit updates the lingering deprecated call
with the new macro as used elsewhere in configure.ac.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
| |
This commit restores the previous behavior with regards to setting some backend options and
restores the ability to set default context options before libusb_init. None of the backends
use anything set in init in their set_option function so this should be safe with all
backends and options.
References #942
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes issue #944 C++ symbol for libusb_set_option not exported correctly.
As per the report in issue #944, original commit is correct but subsequent edits cause the regression.
https://github.com/libusb/libusb/blob/v1.0.22-rc1/libusb/libusb-1.0.def#L156
Closes #964
Signed-off-by: Xiaofan Chen xiaofanc@gmail.com
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
| |
This commit improves the auto-detach code so that it doesn't attempt to detach a kernel
driver if none exists. This will avoid extra info/warning output on the failed detach.
Closes #960
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
| |
interface
The implementation of libusb_kernel_driver_active was attempting to open the interface to
check if a driver is attached. This may have side effects (like configuring the device)
that may be unexpected to the user. This commit updates the code to find the interface's
IO registry entry (either IOUSBHostInterface or the legacy IOUSBInterface) and check if
the entry has a child entry. A child entry indicates that a driver is currently attached.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
| |
This commit adds a call to libusb_kernel_driver_active and prints out the result. This
provides a way to quickly check the result when testing.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes a performance issue caused by the disconnection of the first context
allocated from the default context. usbi_dbg now takes the explicit context instead of
relying on the default context (which may not exist) in most cases. All call sites have
been updated to pass the context or explicitly pass NULL if the context is not
available. We should actively discourage using NULL as the context in the future and
patch all call sites to always pass the context.
Fixes #951
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This resolves an issue introduced by the implementation of the kernel detach code. This
code used claim_interface to detect if a kernel driver is attached. The issue is that if
a driver is attached or the interface is not available and an error message was printed
out. Since this is not an error the info level is more appropriate.
Also downgrading a number of warnings to clean up the output.
Closes #955
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
| |
This commit adds a comment about the bus number calculation to indicate how the
location ID is constructed and why libusb is using the top byte for the bus
number. It also indicates that the bus number starts at 0.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #950
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
| |
Closes #948
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit improves the code around auto attach/detach of a kernel driver:
- Log a warning when a driver can not be auto-detached and continue when claiming an
interface. It could be the case that the interface has no driver attached or that
the claim will still succeed.
- Log a warning if the driver can not be auto-attached and return success when
releasing an interface. The operation did complete successfully but the
re-enumeration may have failed. This can be discovered on the next device
access.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
| |
This commit fixes an issue that can occur if the user calls libusb_close after a failed attempt
of libusb_reset (re-enumerate). This can lead to an attempt to dereference dpriv->device which
was set to NULL during the re-enumeration.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #943
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The option disables device enumeration (and hotplug, which depends on
enumeration). Since this has a much broader usage scope than "weak
authority", give the option a name reflecting what it does.
For now, keep the old option name working as an alias.
Closes #935
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Improve the GUID length check to accommodate the cases where the GUID
string fetched from registry does not have a trailing zero, or if a
multi-string entry, one or two trailing zeroes.
Closes #927
Signed-off-by: Craig Hutchinson <54269136+CraigHutchinson@users.noreply.github.com>
[Tormod: Use correct types and simplify comparisons]
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
| |
Apple documentation says kUSBDeviceSpeedSuper is available in 10.7 and
later but in fact it is only defined in the 10.8 SDK and later.
Closes #410
Closes #929
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit fixes a dangling device reference that can occur when a device is
being re-enumerated. The problem is the code was unconditionally re-caching the
parent device which then takes a reference on the parent device. If the field
was already populated this reference was not needed. To ensure the code works
even if the parent device also changes during the re-enumeration the code
release the parent reference and grabs a fresh reference.
Fixes #924
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
libusb_wrap_sys_device() is an often needed feature on Android, but can
also be very convenient on other Linux platforms.
In many cases the initial device scanning is not needed and
LIBUSB_OPTION_WEAK_AUTHORITY thus provides a performance enhancement.
Closes #925
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
| |
The prior fix made an incorrect assumption about the reference counting of
parent devices. This CL fixes the issue by checking if the parent device
should be removed from the list as well. This is needed as when the child
device is released the parent may also be released.
Closes #924
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
If the device doesn't support the SET_INTERFACE request (which is
allowed if there are no alternate interfaces) it should stall the pipe.
A successful device request would clear all endpoints of the interface.
We therefore plaster over the failed request by clearing the endpoints
and returning success, effectively replacing the missing device request
support.
Up to now this was done by resetting the device, but this would affect
other interfaces as well. So only clear the endpoints of the selected
interface.
Only do this in the case the request tried setting the already
selected setting. Otherwise return the pipe error to the caller.
For any other error than pipe error return with failure.
Note that we need to reclaim the interface after the pipe error.
This is maybe papering over a bug in libusb or darwin: The interface
becomes inaccessible after the failed SetAlternateInterface() call. The
reclaim recovers from it, without device side-effects. The need to
recover was maybe the reason for the original reset "hammer".
Closes #852
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Previously only the dev_id (VID/PID/serial) was checked, but if the
bcdDevice has changed, Windows will have re-enumerated the device and
possibly attributed another ClassGuid to it.
Fixes issue #897.
Closes #900
Thanks to Craig Hutchinson for reporting, suggestion and testing.
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
| |
Fix a typo in the last commit to ensure the loop does exit when there is
a dangling reference.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When cleaning up the context on libusb_exit the last step is to to call
hotplug_exit. This function took one pass over the devices and released any
devices where the reference count had reached 0. All remaining devices
were assumed to have leaked references and a warning message was printed
out. Unfortunately, this cleanup was too simplistic. It ignored the
references created when a device was the parent of another device (which
takes a reference). This reference is released when the child device is
released.
To ensure that we do not erroneously warn about devices with leftover
references the code now loops over the device list until no more devices
have a single reference. This ensures that we will eventually remove
all devices with no external references.
Fixes #924
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
| |
This commit updates libusb_set_option to save the options if setting them on the default
context. This ensures the options 1) can be set before libusb_init(NULL, ...), and 2)
are honored even if the default context is destroyed and re-created.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This commit is similar to #634 but I think it offers a better approach. The commit adds two more methods for querying the port number, in addition to the existing SPDRP_ADDRESS method, which may not actually return the port number when using USB drivers other than the Microsoft driver.
The first method uses SPDRP_LOCATION_INFORMATION, which may return a port in a format similar to "Port_#0002.Hub_#000D".
The second method uses SPDRP_LOCATION_PATHS, which returns the device location in a format similar to "PCIROOT(B2)#PCI(0300)#PCI(0000)#USBROOT(0)#USB(1)#USB(2)#USBMI(3)", where the port number is the number within the last "#USB()" token.
If both methods fail, SPDRP_ADDRESS is still used as a fallback.
Closes #867
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #312
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #914
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
| |
Even though its implementation is in linux/usbfs,
in fact it is under `ifdef` and only used by Android builds.
Closes #916
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
| |
This fixes a bug in the change that removed the library destructor function. We should not
be setting the darwin_cached_devices next and prev pointers to NULL as other parts of
libusb may still have references to the devices (hotplug for example). When those references
are release it may modify darwin_cached_devices. This commit fixes the issue by only
initializing darwin_cached_devices on the very first call to libusb_init and not modifying
darwin_cached_devices in libusb_exit (beyond unrefing the devices).
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Highlights for this change:
- usbi_default_context is only set if libusb_init() is called with NULL.
- All hotplug related functionality (e.g. initialization, processing) has been
moved to hotplug.c
- Backends are simplified by removing initialization mutexes. Mutual exclusion
between init()/exit() is provided by default_context_lock.
- Make hotplug types and functions part of libusbi.h with the common usbi_
prefixes (removes hotplug.h).
Addresses issue highlighted in #855
Closes #856
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
| |
Closes #904
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
| |
Since it calls USBDeviceReEnumerate() and not USBDeviceReset(), we name
it accordingly.
Signed-off-by: Nathan Hjelm <hjelmn@google.com>
|
|
|
|
|
|
|
| |
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>
|
|
|
|
|
|
|
|
|
|
|
| |
Building libusb from another build directory doesn't properly work right
now, as calling autogen.sh from there won't work.
An example is when using jhbuild to build it.
So always use absolute paths to call configure and bootstrap scripts
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
| |
warning: argument 'a4wide' for option PAPER_TYPE is not a valid enum value
Using the default: a4!
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
|
|
| |
warning: Tag 'TCL_SUBST' at line 255 of file 'doxygen.cfg.in' has become obsolete.
This tag has been removed.
warning: Tag 'COLS_IN_ALPHA_INDEX' at line 1056 of file 'doxygen.cfg.in' has become obsolete.
This tag has been removed.
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
|
|
|
|
|
|
|
|
|
| |
A timed out transfer might have been partially filled. Propagate
tpriv->size to avoid dropping this data.
Closes #876
Signed-off-by: Nathan Hjelm <hjelmn@cs.unm.edu>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The commit f74c7f5 "core: new API libusb_set_log_cb() to redirect
global and per context log messages to the provided log handling
function" in 2018-12-05 is present from 1.0.23 onwards.
This commit just adds this to the docs.
Closes #872
Signed-off-by: Victor Toso <victortoso@redhat.com>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The USB spec states that a configuration value of 0 is reserved and is
used to indicate the device in not configured (e.g. is in the address
state). Unfortunately some devices do exist that violate this and use 0
as the bConfigurationValue of the configuration descriptor.
Improve how the Linux backend handles such non-conformant devices by
adding special handling around the configuration value 0. Most devices
will not require this special handling, but for those that do there is
no way to distinguish between the device being unconfigured and using
configuration 0.
Closes #850
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Benjamin Berg reports that some CI systems that simulate sysfs devices
are causing libusb to report errors because such systems are not
conforming to the sysfs pattern of terminating attribute values with a
newline character. Reduce the severity of encountering such
non-conforming attibute values from an error that prevents enumeration
to a warning message.
Closes #857
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
Closes #869
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
| |
Closes #833
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
| |
Commit b51c743e42 ("Windows: Filter out non-libusb I/O completions")
causes problems with the HID backend functions and synchronous transfer
completions. Address these by fetching the correct pointer in the HID
functions and posting an I/O completion for synchronous transfers.
Closes #863
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The I/O completion port thread gets notified of every I/O operation that
completes for a given HANDLE, but not all I/O operations originate from
within libusb. For example, libusbK performs a number of I/O control
calls during initialization and specific device operations, such as
setting an interface alternate setting. These non-libusb operations need
to be ignored as the OVERLAPPED associated with such operations is not
tied to a libusb_transfer structure.
Resolve this situation by using the libusb device handle as the I/O
completion port's unique key and keeping a list of active transfers for
each device handle. When the I/O competion port thread is notified of an
I/O completion, it will first match the OVERLAPPED to an outstanding
transfer before acting on it.
Closes #844
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The AC_CHECK_FUNCS() macro checks whether a program compiled on the host
will link against the function, but it does not help when targeting
older systems where that function is not available. Additionally, the
way that autoconf compiles the program ignores any attributes or
preprocessor guards that installed headers might have applied to that
function.
Resolve this by verifying that the OS X target version is 10.12 or newer
before checking for clock_gettime().
Closes #836
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
|