summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2015-08-03 10:06:05 +0200
committerChris Dickens <christopher.a.dickens@gmail.com>2015-08-04 22:50:54 -0700
commita6a7b53b6312ac06df87e501bf65340b457d0aaf (patch)
tree410031f9ee1c0f2882ff656969d7d5a57b79e8db
parent4fe0f7e7a9c32b6b68bb302236bc675a487d5df5 (diff)
downloadlibusb-a6a7b53b6312ac06df87e501bf65340b457d0aaf.tar.gz
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 <hdegoede@redhat.com>
-rw-r--r--libusb/os/linux_usbfs.c8
-rw-r--r--libusb/version_nano.h2
2 files changed, 9 insertions, 1 deletions
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