Ticket #25 (closed defect: needinfo)

Opened 3 years ago

Last modified 3 years ago

USB bus and device numbers are not zero-padded in the file path on some Linux systems

Reported by: seanni Owned by:
Milestone: Component: libusb-1.0
Keywords: file path Cc:
Blocked By: Blocks:

Description

On my system (Slackware 12.1 -- this may also apply to other distros?), the /dev/bus/usb/... file paths contain non zero-padded USB bus and device numbers. For example, if I want to access device 17 on bus 2, then libusb tries to access the path:

/dev/bus/usb/002/017

However, on my system, the actual path is:

/dev/bus/usb/2/17

The fix required the "obvious" modification to 2 lines in the file ~src/libusb/os/linux_usbfs.c -- I've included the output from diff below:

135c135
<       snprintf(path, PATH_MAX, "%s/%03d/%03d", usbfs_path, dev->bus_number,
---
>       snprintf(path, PATH_MAX, "%s/%d/%d", usbfs_path, dev->bus_number,
832c832
<       snprintf(dirpath, PATH_MAX, "%s/%03d", usbfs_path, busnum);
---
>       snprintf(dirpath, PATH_MAX, "%s/%d", usbfs_path, busnum);

With those changes, it now seems to work correctly.

Change History

comment:1 Changed 3 years ago by dsd

That's a pain. Can you follow up with slackware to see if this is intentional, and why?

I checked Gentoo, Fedora 11, Fedora 12 and latest ubuntu and they all use "zero padding".

comment:2 Changed 3 years ago by dsd

  • Resolution set to needinfo
  • Status changed from new to closed

Please reopen after investigating further. I think this is/was a slackware bug.

Note: See TracTickets for help on using tickets.