diff options
author | Pali Rohár <pali.rohar@gmail.com> | 2018-02-08 23:20:14 +0100 |
---|---|---|
committer | Pali Rohár <pali.rohar@gmail.com> | 2018-02-08 23:20:14 +0100 |
commit | 33442482c65acf3805d24b76b3567ec97c2492ef (patch) | |
tree | bcdc433f2fe01ce6c02d9af5de1dbc8f277c0909 | |
parent | e987dcd94853d0355e36d44e766bfabba62c0df5 (diff) | |
download | 0xFFFF-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
-rw-r--r-- | src/disk.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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; |