Ticket #119 (closed enhancement: fixed)
Opened 20 months ago
Last modified 10 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
Change History
Changed 21 months ago by jhanko
comment:1 Changed 20 months 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 20 months 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!
comment:3 Changed 19 months 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 13 months ago by stuge
- Component changed from libusb-1.0 to libusb-1.0 Linux backend
comment:5 Changed 13 months ago by stuge
- Keywords android usbdev added; Android Linux removed
comment:6 Changed 10 months ago by jhanko
- Owner set to jhanko
- Resolution set to fixed
- Status changed from new to closed
A patch to libusb-1.0.8/libusb/os/linux_usbfs.c which will find the /dev/usbdev* files if the normal places fail.