c - 在c中获取物理硬盘列表

标签 c linux hard-drive

各位,我需要在Linux系统上用C语言获取连接的硬盘列表:

例如,在连接了 2 个 IDE 磁盘和 1 个 SATA 磁盘的计算机上运行程序。

./a.out

需要输出:

/dev/hda
/dev/hdb
/dev/sda

帮助?

最佳答案

使用libsysfs ,这是查询内核有关各种连接设备的推荐方法。

关于c - 在c中获取物理硬盘列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9492577/

相关文章:

c# - 大文件 : impossible to read when they are on an external HD

c - 原始硬盘访问/dev/sda] vs/dev/sg[y]?

linux - 如果满足条件则打印上一行

linux - ASP Net Core Linux ERR_CONNECTION_REFUSED

c# - 如何在 C# .NET 中读取 HDD S.M.A.R.T 寄存器并获取该寄存器的所有关联值?

c - 使用结构时出错,C

c - 非特权用户运行 C/asm 程序会对 Linux 造成什么危害?

c - 线程缓冲区 : how to prevent racing between clients and have client and server working on buffer simultaneously

c - 我想了解一些关于这段代码的信息

c - C 中的范围值