linux: Assume usbfs path = /dev/bus/usb when using UDEV
authorHans de Goede <hdegoede@redhat.com>
Mon, 3 Aug 2015 08:06:05 +0000 (10:06 +0200)
committerChris Dickens <christopher.a.dickens@gmail.com>
Wed, 5 Aug 2015 05:50:54 +0000 (22:50 -0700)
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>
libusb/os/linux_usbfs.c
libusb/version_nano.h

index 9d9d00e..5164616 100644 (file)
@@ -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);
 
index 74cfbd2..7b92667 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 10993
+#define LIBUSB_NANO 10994