I want to retrieve SCSI hard drive serial on Linux (Ubuntu) from a C++ program without root priveleges. I tried ioctl(fd, HDIO_GET_IDENTITY, &id) but it seems to work only for ATA devices. Does anyone have a solution for SCSI HDDs? The solution I am looking for should not require the user to have root priveleges. Any source code will be much appreciated
Share
How about sending a SCSI Inquiry command, as described here: 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
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