Google
  Web www.spinics.net

Re: USB bus unique ID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


On Tue, 4 Dec 2007, Alessio Sangalli wrote:

> Hi, do you know a way to read a unique ID for a USB bus? I would like to
> assign a given USB port to some application; I now
> read /sys/bus/usb/devices/usb* but it seems the bus* links can be
> assigned to different entities from a boot to another.
> 
> Is there some kind of unique bus ID inside /sys/bus/usb/devices/usb* so
> that I can safely assign the given bus to the application?
> 
> Am I confused enough :) ??

There is an "almost" unique bus ID you can use, given by the target of
the usbN symbolic link.  It doesn't change unless you alter the
hardware in your PC.

For example, on my system the usb1 bus currently corresponds to:

$ ls -l /sys/bus/usb/devices/usb1
lrwxrwxrwx 1 root root 0 Dec  4 14:16 /sys/bus/usb/devices/usb1 -> 
../../../devices/pci0000:00/0000:00:1d.0/usb1/

Now that bus's label may change from one boot to another, sometimes 
usb1, sometimes usb5, and so on.  But whatever the label is, that bus 
will always be associated with "devices/pci0000:00/0000:00:1d.0/".

You can get at the same information in reverse.  Now that I know the
path, it's enough to do this:

$ echo /sys/devices/pci0000:00/0000:00:1d.0/usb*
/sys/devices/pci0000:00/0000:00:1d.0/usb1 
/sys/devices/pci0000:00/0000:00:1d.0/usb_host:usb_host1

This says that right now, that particular bus is labelled "usb1".

Alan Stern


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________
Linux-usb-users@xxxxxxxxxxxxxxxxxxxxx
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users

[Linux USB]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]    [Yosemite Photos]    [Video Projectors]     [PDAs]     [Free Online Dating]     [Hacking TiVo]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Devices]     [Big List of Linux Books]     [16.7MP]