如何使用C语言确定存储类型(SSD驱动器或HHD机械驱动器) [英] How to determine storage type (SSD drive or HHD .mechanical drive), using C language

查看:100
本文介绍了如何使用C语言确定存储类型(SSD驱动器或HHD机械驱动器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从C程序读取驱动器的硬件信息? (即确定驱动器是SSD还是机械磁盘.)

How can I, from a C program, read the hardware information of a drive? (I.e. to determine if the drive is an SSD or a mechanical disk.)

推荐答案

SSD应该将自己标识为非旋转.以linux为例,您可以通过sysfs获取信息:

SSD are supposed to identify themselves as non-rotative. For linux, as example, you can get the info via sysfs:

cat /sys/block/sda/queue/rotational

如果返回0,则说明您有SSD ...

If it returns 0, you have SSD...

这篇关于如何使用C语言确定存储类型(SSD驱动器或HHD机械驱动器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆