1
votes

I have problem in my c program which is transferring/copying data to/from /dev/sda and /dev/sdb.(open, read, write) Both devices are USB pendrives and their Major number is 8.

The problem i have is that minor numbers change exactly like the sda sdb names så after reboot i often write/read from/to the wrong one as the /dev/name become assigned to other device.

To make it more complicated the both USB devices are both connected to same USB bus (Raspberry Pi has only one) and have same size. What is different is the manufacturer name.

How to check the difference in c?

thanks in advance.

1
I think that you should investigate udev and /sys/ and perhaps /proc/mounts and other files under /proc/Basile Starynkevitch

1 Answers

1
votes

udev should be solving that for you by creating unique names under /dev/disk which you can use instead of /dev/sda and /dev/sdb. The links under /dev/disk/by-id also include manufacturer name.