How can I grab the hard drive serial number in C on a machine running FreeBSD? The hard drive in question is an mSATA SSD. Specifically the TS256GMSA370.
In my searching I found the following on this forum: Thread 9548
I receive the error 'Inappropriate ioctl for device' when running the following:
From my understanding, this code is for ATA devices. When running camcontrol I receive the following:
Now, I can, as a last resort, execute the camcontrol command within C and extract the serial this way. However, I'd prefer to grab the serial natively in C.
Is there an ioctl command that will allow me to grab the serial from an mSATA SSD, or perhaps another method besides ioctl?
Solution
In my searching I found the following on this forum: Thread 9548
I receive the error 'Inappropriate ioctl for device' when running the following:
PHP:
ioctl(fd, IOCATAGPARM, &atap);
From my understanding, this code is for ATA devices. When running camcontrol I receive the following:
Code:
camcontrol identify /dev/ada0
protocol ATA/ATAPI-9 SATA 3.x
device model TS256GMSA370
Is there an ioctl command that will allow me to grab the serial from an mSATA SSD, or perhaps another method besides ioctl?
Solution
/usr/src/usr.sbin/diskinfo/diskinfo.c has
Code:... if (ioctl(fd, DIOCGIDENT, ident) == 0) ...