From a6a7b53b6312ac06df87e501bf65340b457d0aaf Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 3 Aug 2015 10:06:05 +0200 Subject: linux: Assume usbfs path = /dev/bus/usb when using UDEV On some exotic hardware, e.g. HP ProLiant Moonshot Cartridge servers there are no usb controllers, so no usb devices at all. In this case currently libusb_init will fail, because find_usbfs_path fails. Many apps don't handle this gracefully, and even if they do not crash the result still is not pretty, e.g.: unable to initialize libusb: -99 Where one simply would expect empty output. Since on systems using udev the usbfs path should always be /dev/bus/usb (as that gets created by udev), simply assume /dev/bus/usb when build with USE_UDEV and the path cannot be found in the traditional way. Signed-off-by: Hans de Goede --- libusb/os/linux_usbfs.c | 8 ++++++++ libusb/version_nano.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 9d9d00e..5164616 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -307,6 +307,14 @@ static const char *find_usbfs_path(void) } } +/* On udev based systems without any usb-devices /dev/bus/usb will not + * exist. So if we've not found anything and we're using udev for hotplug + * simply assume /dev/bus/usb rather then making libusb_init fail. */ +#if defined(USE_UDEV) + if (ret == NULL) + ret = "/dev/bus/usb"; +#endif + if (ret != NULL) usbi_dbg("found usbfs at %s", ret); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 74cfbd2..7b92667 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10993 +#define LIBUSB_NANO 10994 -- cgit v1.2.1