How to find a device node in /dev from physical USB port?
<p>Given two identical USB devices with <strong>the exact same USB descriptors</strong> and thus with absolutely no way to differentiate them only using the leaf information of the device information view (the USB device descriptor) as usually done (yes, this device is badly designed).</p>

<p>But since I am talking about a closed system, I thought I could solve the problem using the physical USB ports used to connect the devices. I can tell that one is plugged on the physical port #1 and the other is plugged on the physical port #2 of my motherboard's root usb hub. And <code>lsusb</code> gives me this information.</p>

<p>So now I need to be able to find the device node in <code>/dev</code> according to these two physical coordinates only. But when looking at <code>sysfs</code>, I can't find any link to this physical topology. Like if the <code>sysfs</code> usb tree was only a logical view of the physical's. And it seems <code>sysfs</code> usb devices names like <code>/sys/bus/usb/devices/2-2.1</code> or <code>/sys/bus/usb/devices/2-2.1/2-2.2</code> are dynamic and unpredictable.</p>

<p>I found this:</p>

<pre><code>$ ls /dev/serial/by-path/ pci-0000:02:00.0-usb-0:2.1:1.0-port0@ 
pci-0000:02:00.0-usb-0:2.2:1.0-port0@
</code></pre>

<p>Should I write <code>udev</code> rules to freeze the pci and usb port names? Are they already predictable?</p>

<p>My final goal is to be able to write a <code>udev</code> rule to obtain predictable and frozen device's names according to the physical usb port used.</p>

<p>The solution could also apply to a PCI device.</p>

<p>Thanks</p>