Linux 内核中 USB 设备和 HDD 设备的盘符
如何为 USB/HDD 驱动器分配驱动器盘符?我的意思是在代码级别。我查看了代码,注意到gendisk struct
具有disk_name。这给出了sda/sdb/sdc....等
。但是,如果磁盘被检测为sda1、sdc1...
,那么这些名称可以从结构/代码中获取吗?
How the drive letter is assigned to USB/HDD drives? I meant in the code level. I looked at the code and noticed that the gendisk struct
having the disk_name. that gives sda/sdb/sdc....etc
. But if the disk is detected as sda1, sdc1...
then where these names can be get form the structures/code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
sda/sdb等是代表整个驱动器的块设备。当驱动器被分区时,您将看到 sda1、sdc1 等。这些块设备仅用于访问该分区。
我对代码并不熟悉,但希望这能帮助您指明正确的方向。
sda/sdb, etc are the block device representing the entire drive. When the drive is partitioned, you will see the sda1, sdc1, etc. These block devices are used to access just that partition.
I'm not familiar with the code specifically, but hopefully this will help point you in the right direction.
一个有用的代码调查起点是函数
disk_name()
,在block/partition-generic.c
中定义:One useful investigation starting point code-wise would be function
disk_name()
, defined inblock/partition-generic.c
: