1

here is my situation, I am writing a c program in linux and in the program I am mounting 2 usb devices attached to 2 specific ports in the computer. (eg : I have to mount the usb attached to the left port in to /mnt/left and the right port to /mnt/right) and the attachment order of those devices may differ (eg: left port usb may or may not be attached before the right.) In this case what should i do?

1 Answer 1

1

Again we meet.

Here you have your USB ports. Check which is for left and which is for right -> /sys/bus/usb/devices. When you attach device to usb port, you will get a dmesg message about to which port it is attached. Something like this:

input: Logitech USB Receiver as /devices/pci0000:00/0000:00:1d.2/usb4/4-1/4-1:1.0/input/input

You just need to pair your usb device with the port.

2
  • Hi tdi, since I am a newb to linux, Can you please elaborate your answer? Actually I want to mount any usb device attached to left port (say port1) to one location and the right to another location meaning that the left port usb device and the right port device can change with time. (I may mount different usb devices to left/right port with time.) and this has to be written in a c program. (the program runs every time a usb is attached.) thank you.
    – gsk
    Mar 27, 2011 at 17:45
  • Hi tdi, I think I found the answer. It has to be done using 'udev' rules. thank you for your interest.
    – gsk
    Mar 28, 2011 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .