[英]how in c check what exactly is under /dev/sda and what is under /dev/sdb when both are USB drives
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. 我的c程序在/ dev / sda和/ dev / sdb之间传输数据/从中复制数据时遇到问题。(打开,读取,写入)这两个设备都是USB Pendrives,它们的主要编号是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. 我的问题是,较小的数字更改与重新启动后的sda sdb名称完全相同,因为/ dev / name分配给其他设备时,我经常从错误的目录中读取/读取错误的数据。
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. 更复杂的是,两个USB设备都连接到相同的USB总线(Raspberry Pi只有一个)并且具有相同的大小。 What is different is the manufacturer name. 制造商名称不同。
How to check the difference in c? 如何检查c的差异?
thanks in advance. 提前致谢。
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. udev应该通过在/ dev / disk下创建唯一的名称(而不是/ dev / sda和/ dev / sdb)来解决此问题。 The links under /dev/disk/by-id also include manufacturer name. / dev / disk / by-id下的链接还包括制造商名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.