简体   繁体   English

通过C ++程序在Linux上获取SCSI硬盘驱动器串行

[英]Get SCSI hard drive serial on Linux from a C++ program

I want to retrieve SCSI hard drive serial on Linux (Ubuntu) from a C++ program without root priveleges. 我想从没有根特权的C ++程序中检索Linux(Ubuntu)上的SCSI硬盘串行。 I tried ioctl(fd, HDIO_GET_IDENTITY, &id) but it seems to work only for ATA devices. 我尝试了ioctl(fd,HDIO_GET_IDENTITY,&id),但它似乎仅适用于ATA设备。 Does anyone have a solution for SCSI HDDs? 有没有人为SCSI硬盘提供解决方案? The solution I am looking for should not require the user to have root priveleges. 我正在寻找的解决方案不应要求用户具有root特权。 Any source code will be much appreciated 任何源代码将不胜感激

How about sending a SCSI Inquiry command , as described here: http://tldp.org/HOWTO/archived/SCSI-Programming-HOWTO/SCSI-Programming-HOWTO-9.html 如何发送SCSI查询命令 (如此处所述): http : //tldp.org/HOWTO/archived/SCSI-Programming-HOWTO/SCSI-Programming-HOWTO-9.html

A complete program: http://tldp.org/HOWTO/archived/SCSI-Programming-HOWTO/SCSI-Programming-HOWTO-24.html 完整程序: http//tldp.org/HOWTO/archived/SCSI-Programming-HOWTO/SCSI-Programming-HOWTO-24.html

Edit: The bottom of this page shows the specific structures required for the SCSI serial number inquiry request and response: http://sunbolic.com/sunbolic/code/cpp/aspi_unit_sn.htm 编辑:此页面底部显示SCSI序列号查询请求和响应所需的特定结构: http : //sunbolic.com/sunbolic/code/cpp/aspi_unit_sn.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM