简体   繁体   English

在c中如何检查/ dev / sda下到底是什么以及当两个都是USB驱动器时在/ dev / sdb下是什么

[英]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.

相关问题 如何在Linux中以编程方式获取磁盘名称(如“/ dev / sda”或“/ dev / sdb”)? - How to get disk name programmatically in Linux(Like “/dev/sda” or “/dev/sdb”)? 这种连续C内存分配的方法到底是做什么的? - What exactly is this method of contiguous C memory allocation doing under the hood? 当您将字符串传递给 C 中的函数时,幕后会发生什么 - What happens under the hood when you pass a string to a function in C C-如何在Linux下重置USB总线? - C - how can i reset the USB Bus under linux? dev c++ 和在线编译器有什么区别? - What is the difference between dev c++ and online compiler? 在 android 如何使用 c function 找到用于触摸屏的 /dev/input/event* - In android how to find what /dev/input/event* is used for touchscreen using c function 使用BlueZ将libbluetooth1-dev替换为C编程的是什么? - What replaced libbluetooth1-dev for C programming using BlueZ? 大会之下存在什么? - What exists under Assembly? 从 /dev/tty 读取时,输入和键盘缓冲区中发生了什么? - When reading from /dev/tty, what is happening in input and keyboard buffer? Linux下如何在C中确定USB存储器(USB闪存驱动器)“设备路径” - how to determine USB storage (USB flash drive) 'device path' in C under Linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM