Ticket #119 (closed enhancement: fixed)

Opened 3 years ago

Last modified 21 months ago

[PATCH] Enable support for Linux systems without either usbfs or udev (e.g. Android)

Reported by: jhanko Owned by: jhanko
Milestone: Component: libusb-1.0 Linux backend
Keywords: android usbfs udev usbdev Cc:
Blocked By: Blocks:

Description

Usbfs (which will name USB device special files as "/proc/bus/usb/<bus>/<device>") has been deprecated due to security problems. Instead, most modern Linux systems use the udev subsystem to name the files "/dev/bus/usb/<bus>/<device>". Libusb will currently find the device files in either place.

However, many embedded Linux systems, including Android, do not include the udev subsystem. Additionally, usbfs is typically not included due to its deprecated status. Instead, they name the USB device special files as "/dev/usbdev<bus>.<device>" via the CONFIG_USB_DEVICE_CLASS option (see: drivers/usb/core/devio.c).

This is a request to enhance libusb-1.x to be able to find the USB device special files by name in the /dev directory.

Attached is a patch to libusb-1.0.8/libusb/os/linux_usbfs.c which will find the /dev/usbdev* files if the normal places fail. Support is enabled by defining CONFIG_WO_BUS_DIRS.

Attachments

libusb-1.0.8_patch (3.4 KB) - added by jhanko 3 years ago.
A patch to libusb-1.0.8/libusb/os/linux_usbfs.c which will find the /dev/usbdev* files if the normal places fail.
libusb-git.patch (3.2 KB) - added by jhanko 2 years ago.
Patch to libusb-stuge.git master as per comments one and two

Download all attachments as: .zip

Change History

Changed 3 years ago by jhanko

A patch to libusb-1.0.8/libusb/os/linux_usbfs.c which will find the /dev/usbdev* files if the normal places fail.

comment:1 Changed 3 years ago by stuge

I like this idea. It is very simple to fall back to also check these device nodes if all else fails. Can you rework the patch so that it does this, ie. that it will always check these device nodes if the other lookup methods fail, and have it apply on top of libusb-stuge.git master. Thanks!

comment:2 Changed 3 years ago by stuge

Oh, one more comment. The patch has some defines for the path to use, but this path has been hard coded in the kernel sources since the code there was added in 2005, so please do the same in libusb.

Also note that adding this extra device node source may require a little bit of restructuring of the Linux device node handling. Not very much, but in any case there can be no #ifdefs for this change to libusb.

Thanks!

Changed 2 years ago by jhanko

Patch to libusb-stuge.git master as per comments one and two

comment:3 Changed 2 years ago by jhanko

I took out all the #ifdefs and integrated the change directly into the top of the current (as of 19 Oct 2011) libusb-stuge.git master repository. It will now always look for /dev/usbdev*.* devices if /dev/bus/usb and /proc/bus/usb are both missing.

The second patch (libusb-git.patch) reflects the merge. I tested it on embedded devices using usbdev*.* naming, both with and without sysfs support.

comment:4 Changed 2 years ago by stuge

  • Component changed from libusb-1.0 to libusb-1.0 Linux backend

comment:5 Changed 2 years ago by stuge

  • Keywords android usbdev added; Android Linux removed

comment:6 Changed 21 months ago by jhanko

  • Owner set to jhanko
  • Resolution set to fixed
  • Status changed from new to closed

In 05cbe2de45806db309343cdf298d8569c55863e5/libusb:

Linux: Search for /dev/usbdev<bus>.<device> USB device special files

If neither the (now deprecated) usbfs filesystem nor udev is available
then libusb searches for device nodes also in /dev where they may be
created if the kernel was built with the option CONFIG_USB_DEVICE_CLASS.
This helps on embedded systems such as Android, and all mdev users.

Fixes #119.

Note: See TracTickets for help on using tickets.