Hi everyone, I'm trying to construct a program running on Ubuntu to meet the requirements below, but I have faced some problem...

When 4 USB storage devices of the same kind/class are plugged in USB port of an Ubuntu PC, I want to --
1. Get the mount path of each device;
2. Get the device physical port number of each device.
Ubuntu has been set to automatically mount USB devices.

Current progress:
1. Via lsusb, I can get the device name, device number of each device.
2. Via lsusb -t, I can get the device number and device physical port number of each device.
3. Now when one device named 'userfs' is plugged in, I can first confirm the device number of it by device name via lsusb, and then confirm the device physical port number by device number via lsusb -t.
Well, now I know its device physical port number but don't know its mount path.
4. Now I can use mount command and get its mount path...wait! How can I know which one of the mounted paths listed by mount command is bound with my USB storage device 'userfs'? ---For some reason, my devices named 'userfs' will always be mounted to /dev/userfs/. That's it. (if two or more USB devices of this kind are mounted, one will be mounted to /dev/userfs, the seconds /dev/userfs_, the third /dev/userfs__, the forth /dev/userfs___)

Till now, I get both the mount path and device physical port number of ONE USB device named 'userfs'.

BUT no...It's meaningless for my goal.
What I want is an algorithm which can get themount path and device physical port number of each device when FOUR USB devices are plugged in.

Although lsusb/lsusb -t can get each device physical port number of them, and mount command can get each mount path of them, but I don't know which device physical port number is bound with one of the mount path...Four USB devices share the same device name, so I can't tell them from each other when I use lsusb or lsusb -t.

I've also checked the code of lsusb and mount, and found they used different methods to get the information and there was not any 'link information' collected by both of the tools to let me make sure 'which port matches which mount path'.

Could any one help me and give me some suggestion? C++ code and shell script are both OK.