I have looked at DADiskCopyDescription
and enumerating IOUSBDevice
from IOKit and neither provide me with the serial number of the USB hard drive. The latter provides a USB Serial number which is not equivalent to its hard drive serial number. How do I get that (in c/c++, NOT via the shell)?
Asked
Active
Viewed 1,669 times
6

chacham15
- 13,719
- 26
- 104
- 207
-
1possible duplicate of [Get Serial Number of USB HDD (Mac OS)](http://stackoverflow.com/questions/10348318/get-serial-number-of-usb-hdd-mac-os) – John Zwinck Apr 27 '13 at 04:37
-
2@JohnZwinck nope, that solution is the `IOUSBDevice` I referenced in the question. I.e. it only gives the USB serial, not the HD serial. – chacham15 Apr 27 '13 at 10:05
1 Answers
5
What you are basically asking is "How do I directly communicate with a hard drive over USB?"
The answer is: It depends on the USB controller. Not all controllers support your request.
The following conditions must exist:
- The USB bridge must support ATA pass-through (if ATA)
- SCSI must be supported on the host OS
- The OS must provide a SCSI pass-through API (Yes on Windows and Linux, No on MacOS X)
Another factor arises: Some controllers support drive manufacturer-independent passthroughs, but some support different commands based on the hard drive they are controlling. This also depends on whether the attached drive is PATA, SATA/SAS, or SCSI.
Examples of controllers that support at least one of the above include Sunplus SPIF215/6, SPIF225/6; JMicron JM20329, JM20335-39; and Cypress CY7C68300B/C (AT2LP), CY7C68310 (ISD-300LP).
Wish I had happier news for you.

Charles Burns
- 10,310
- 7
- 64
- 81
-
Interesting. Windows manages to give me the correct (drive) serial number without any special work. I.e. without any sort of pass through on my part. Is there something similar for OS X? So, are you saying that it is impossible on OS X? – chacham15 Jun 02 '13 at 19:34
-
I suspect your USB controller passes the serial # request through to the drive. Re: MacOSX: Nothing's impossible, but it may involve more work. To get started, take a look at: http://comments.gmane.org/gmane.linux.utilities.smartmontools/6812 `Until the very recent version of smartmontools (5.39), SMART through USB was not possible on Mac OS X, because the Mac OS X kernel does not support SCSI pass through...` – Charles Burns Jun 02 '13 at 19:54