0
我在FreeBSD11上。我想要获得连接到我的系统的所有设备并使用C++保存它们的信息。为此,我运行camcontrol devlist
命令。输出是:用C++获取设备列表
<OCZ-VERTEX4 1.4.1.3> at scbus0 target 0 lun 0 (pass0,ada0)
<OCZ-AGILITY3 2.15> at scbus0 target 1 lun 0 (pass1,ada1)
<OCZ-AGILITY3 2.15> at scbus1 target 0 lun 0 (pass2,ada2)
<OCZ-AGILITY3 2.15> at scbus1 target 1 lun 0 (pass3,ada3)
<OCZ-AGILITY3 2.15> at scbus3 target 0 lun 0 (pass4,ada4)
< USB FLASH DRIVE PMAP> at scbus4 target 0 lun 0 (da0,pass5)
我把这个输出在一个文件中,用getline
在C++中,只得到从在scbus0靶0 LUN 0(pass0,ada0)线和忽略第一部分。
我想ada0,ADA1,ADA2,ada3,ada4,DA0然后用/usr/local/sbin/smartctl -i /dev/<device>
得到它的信息和其他例如da0,CD0,...不会有输出在此命令保存他们的名字。
我不确定这是否是一种好方法。如果存在,请给我一个更好的解决方案,或者帮助我解决我的问题。
谢谢您的回复。看起来** camcontrol.c **非常适合这个原因,但我不知道该如何使用此代码。你能举个例子吗? Thnks –