summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2018-02-08 23:20:14 +0100
committerPali Rohár <pali.rohar@gmail.com>2018-02-08 23:20:14 +0100
commit33442482c65acf3805d24b76b3567ec97c2492ef (patch)
treebcdc433f2fe01ce6c02d9af5de1dbc8f277c0909 /src
parente987dcd94853d0355e36d44e766bfabba62c0df5 (diff)
download0xFFFF-33442482c65acf3805d24b76b3567ec97c2492ef.tar.bz2
disk: Fix detection of busnum
Unpatched version of libusb on linux platform does not set location, but Debian's version of libusb has a patch which set it. For compatibility with other systems without unpatched libusb version, read busnum from dirname which seems to be always set. Fixes: https://github.com/pali/0xFFFF/issues/5
Diffstat (limited to 'src')
-rw-r--r--src/disk.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/disk.c b/src/disk.c
index c048a56..f58b1dd 100644
--- a/src/disk.c
+++ b/src/disk.c
@@ -363,9 +363,17 @@ int disk_init(struct usb_device_info * dev) {
fclose(f);
- if ( devnum != device->devnum || device->bus->location != busnum )
+ if ( device->devnum != devnum )
continue;
+ if ( device->bus->location ) {
+ if ( device->bus->location != busnum )
+ continue;
+ } else if ( device->bus->dirname[0] ) {
+ if ( atoi(device->bus->dirname) != (int)busnum )
+ continue;
+ }
+
if ( sscanf(dirent->d_name, "%d:%d", &maj2, &min2) != 2 ) {
maj2 = -1;
min2 = -1;