From 33442482c65acf3805d24b76b3567ec97c2492ef Mon Sep 17 00:00:00 2001 From: Pali Rohár Date: Thu, 8 Feb 2018 23:20:14 +0100 Subject: 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 --- src/disk.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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; -- cgit v1.2.3