lsusb : Fix or remove -t option

Bug #159189 reported by Erik de Castro Lopo
50
This bug affects 2 people
Affects Status Importance Assigned to Milestone
usbutils (Debian)
Fix Released
Unknown
usbutils (Gentoo Linux)
Fix Released
Low
usbutils (Ubuntu)
Low
Unassigned

Bug Description

In Gutsy, the /proc/bus/usb tree has been removed (for seemingly good reason, see https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/156085/comments/6), but the lsusb command doesn't work quite right without access to the file /proc/bus/usb/devices.

In particular the "lsusb -t" command gives:

cannot open /proc/bus/usb/devices, No such file or directory

Since (according to the above comment) /proc/bus/usb is broken, lsusb should have the -t option fixed or removed.

Related branches

Revision history for this message
ciskje (ferrara) wrote :

Confirmed

Revision history for this message
Brian Pitts (bpitts) wrote :

Confirmed

Revision history for this message
Martijn vdS (martijn) wrote :

Confirmed

Changed in usbutils:
status: New → Confirmed
Revision history for this message
Xiaofan Chen (xiaofanc) wrote :

This bug seems to still exist in Ubuntu 8.04.

I think it is better to patch usbutils (lsusb) to remove the "-t" option.

mcuee@ubuntu804:~$ uname -a
Linux ubuntu804 2.6.24-16-generic #1 SMP Thu Apr 10 13:23:42 UTC 2008 i686 GNU/Linux
mcuee@ubuntu804:~$ lsusb -t
cannot open /proc/bus/usb/devices, No such file or directory (2)

Changed in usbutils:
importance: Undecided → Low
milestone: none → ubuntu-8.10
Revision history for this message
AhmedElhasairi (ahmedelhassairi) wrote :

I am new here so please be patient if I make some mistakes.
I have followed Xiaofan suggestion and removed the -t option completely from lsusb source code and attached is the .diff file generated as a result. Is this the correct procedure for patching a package or not?
Thanks
Ahmed

Revision history for this message
AhmedElhasairi (ahmedelhassairi) wrote :

Here is the .debdiff file

Revision history for this message
Daniel Holbach (dholbach) wrote : Sponsor Request

Colin: can you please take a look at it?

Revision history for this message
Henry (hua-zhang) wrote :

From https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/156085/comments/6, we can see, it's truned to use /dev/bus/usb, why not turn to use this one as a fix?

Revision history for this message
AhmedElhasairi (ahmedelhassairi) wrote :

I thought of using /dev/bus/usb, but the entire directory structure has changed. there is no devices file anymore. so using /dev/bus/usb will require us to change the source code of lsusb quite alot, which I thought should be discussed with upstream first. At the moment I am working on the changes when I finish them I will let upstream have a look.

Revision history for this message
Venzen (venzen) wrote : Re: [Bug 159189] Re: lsusb : Fix or remove -t option

Interesting, /proc/bus/usb on my Ubuntu 8.04 workstation is an empty
directory eventho' I have several USB devices connected...

On Mon, 2008-06-30 at 03:33 +0000, Henry wrote:
> From
> https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/156085/comments/6, we
> can see, it's truned to use /dev/bus/usb, why not turn to use this one
> as a fix?
>

Revision history for this message
Oliver Grawert (ogra) wrote :

you likely would want /sys/bus/usb instaed ...

Revision history for this message
Colin Watson (cjwatson) wrote :

I don't think I'm happy about just removing the -t option, so I'd rather not apply this patch. There should be time in the intrepid cycle to fix it properly, shouldn't there?

Revision history for this message
SebastianReschke (sebastianreschke) wrote :

If you first mount usbfs e.g. with the following command lsusb -t works fine.

sudo mount -t usbfs none /proc/bus/usb

Revision history for this message
Oliver Grawert (ogra) wrote :

please try to use sysfs for a proper fix rather than reintroducing the obsolete usbfs, i would love to work on it but am very short on time for intrepid to take extra actions atm. if someone wants to produce a proper patch i'd be willing to review and merge it though.

Revision history for this message
AhmedElhasairi (ahmedelhassairi) wrote :

I might be able to produce a prober patch, but I'm still new and don't know
my way around, and I have no working linux machine at the moment. when I get
back next week I will try to help the best way I can.

On 7/24/08, Oliver Grawert <email address hidden> wrote:
>
> please try to use sysfs for a proper fix rather than reintroducing the
> obsolete usbfs, i would love to work on it but am very short on time for
> intrepid to take extra actions atm. if someone wants to produce a proper
> patch i'd be willing to review and merge it though.
>
> --
> lsusb : Fix or remove -t option
> https://bugs.launchpad.net/bugs/159189
> You received this bug notification because you are a direct subscriber
> of the bug.
>
> Status in "usbutils" source package in Ubuntu: Confirmed
>
> Bug description:
> In Gutsy, the /proc/bus/usb tree has been removed (for seemingly good
> reason, see
> https://bugs.launchpad.net/ubuntu/+source/kvm/+bug/156085/comments/6), but
> the lsusb command doesn't work quite right without access to the file
> /proc/bus/usb/devices.
>
> In particular the "lsusb -t" command gives:
>
> cannot open /proc/bus/usb/devices, No such file or directory
>
> Since (according to the above comment) /proc/bus/usb is broken, lsusb
> should have the -t option fixed or removed.
>

Changed in usbutils:
assignee: nobody → ahmedelhassairi
status: Confirmed → In Progress
Revision history for this message
AhmedElhasairi (ahmedelhassairi) wrote :

Attached is a patch that uses the sysfs structure I haven't throughly tested as I don't have a usb hub to connect directly to my laptop.
Please take a look and let me know of any thing is required from me.

Changed in usbutils:
assignee: ahmedelhassairi → nobody
status: In Progress → Confirmed
Revision history for this message
Colin Watson (cjwatson) wrote :

Please try to make sure to follow the coding style of the surrounding code. usbutils seems to be largely in the Linux kernel's style, so I had to clean up quite a few things in order to be free enough of distractions to read the actual code changes:

  * various whitespace changes, e.g. consistent use of tabs for indentation
  * write comments as C89-style /* ... */ rather than C++/C99-style //...
  * consistent brace style

I reverted your le16_to_cpu changes, which seemed quite unnecessary.

Your formatting is, to say the least, extremely misleading. updateusblist has code that looks like this:

        if (!(bus = malloc(sizeof(struct usbbusnode))))
                lprintf(0, "Out of memory\n");
                bus->busnum = busnum;
...

This looks just like you forgot to put a brace after the if, but actually it seems to be intentional! Please be disciplined about indentation levels to avoid confusion; good editors can often help with this.

I factored out a bit of duplicate code near the end of findtree.

Don't redeclare file_select locally in treedump.

You misspelled "struct dirent" as "struct direct". This produced a compiler warning:

  ../lsusb.c:2777: warning: passing argument 3 of ‘scandir’ from incompatible pointer type

The recursion case for level in findtree doesn't work right; you need to increment it in the recursive call to findtree, not just before exiting the function (which achieves nothing since it's passed by value).

The condition for path construction in findtree needs to be level >= 1, not level >= 2. (I noticed this by comparing lsusb output before and after this change.)

Other than that, this seems to work well, thanks, and I've uploaded this. I've attached the final debdiff here, and I suggest you read over it for future reference.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package usbutils - 0.73-8ubuntu2

---------------
usbutils (0.73-8ubuntu2) intrepid; urgency=low

  * Apply patch from Ahmed Elhasairi <email address hidden>, somewhat
    modified by me, to fix 'lsusb -t' (LP: #159189):
    - Remove dependency on usbfs.
    - Add support for sysfs.

 -- Colin Watson <email address hidden> Tue, 02 Sep 2008 18:20:06 +0100

Changed in usbutils:
status: Confirmed → Fix Released
Revision history for this message
In , Denilson Sá (denilsonsa) wrote :

The usbfs mount point /proc/bus/usb is deprecated.
The -t option of lsusb (from sys-apps/usbutils package) relies on /proc/bus/usb/devices.

Ubuntu guys have developed a patch to make -t work even without usbfs.
The patch is pretty new, and has been just released:
https://bugs.launchpad.net/ubuntu/+source/usbutils/+bug/159189

Maybe Gentoo people could benefit from such patch, so I'm opening this bug here (and also because if more people revise/test such patch, better for everyone). Of course, the best thing is to have such patch approved and applied upstream.

Revision history for this message
In , Wormo (wormo) wrote :

Thanks for the suggestion, assigning to maintainers.

Revision history for this message
Ricky Campbell (cyberdork33) wrote :

Confirming fix in usbutils_0.73-8ubuntu2

Changed in usbutils:
status: Unknown → New
Changed in usbutils:
status: Unknown → Confirmed
Revision history for this message
Bremm (bremm) wrote :

$ lsusb -t
2-6:1.2: No such file or directory
/: Bus 02.Port 1: Dev 1, Class=root_hub, Driver=ohci_hcd/10p, 12M
    |__ Port 2: Dev 2, If 0, Class=HID, Driver=usbhid, 1.5M
    |__ Port 9: Dev 26, If 0, Class=HID, Driver=usbhid, 1.5M
    |__ Port 10: Dev 25, If 0, Class=HID, Driver=usbhid, 1.5M
    |__ Port 10: Dev 25, If 1, Class=HID, Driver=usbhid, 1.5M
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=ehci_hcd/10p, 480M

$ dpkg-query -W usbutils
usbutils 0.82-0ubuntu1

Revision history for this message
Andrei Emeltchenko (andrei-emeltchenko-finik) wrote :

Reproduced with 9.10

3-1:1.2: No such file or directory
3-1:1.3: No such file or directory
3-2:1.0: No such file or directory
/: Bus 07.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 06.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 05.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=uhci_hcd/2p, 12M

Revision history for this message
Venzen (venzen) wrote :

$ lsusb -t

Works for me since 10.04

Changed in usbutils (Gentoo Linux):
importance: Unknown → Low
Changed in usbutils (Debian):
status: New → Fix Released
Revision history for this message
In , Mike Frysinger (vapier) wrote :

latest version uses sysfs

Changed in usbutils (Gentoo Linux):
status: Confirmed → Fix Released
Revision history for this message
thinkpad (fellowsgarden) wrote :

in "ubuntu precise" still return "no such file or directory".

has the "fix released" also been applied to "ubuntu precise" ?

aslijing (aslijing123)
Changed in usbutils (Ubuntu):
assignee: nobody → aslijing (aslijing123)
assignee: aslijing (aslijing123) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.