ATAIdentify: was Re: Darwin-dev Digest, Vol 3, Issue 158
ATAIdentify: was Re: Darwin-dev Digest, Vol 3, Issue 158
- Subject: ATAIdentify: was Re: Darwin-dev Digest, Vol 3, Issue 158
- From: Peter Cassidy <email@hidden>
- Date: Thu, 15 Jun 2006 20:25:27 +0100
On 15 Jun 2006, at 20:02, email@hidden wrote;
I'd like to retrieve the system volume's hard disk serial number.
For drives which indeed support such a serial number it can be read
using the ioreg tool.
Although I'd prefer to read the hard disk serial number using an API
(e.g. IOKit) instead of using a dedicated tool, I'm more concerned
about the different paths I seem to have to go through the
dictionaries to get different drives' serial numbers when the drives
are attached by different busses (see ioreg output below).
It's part of the SMART API. I used it when hacking SMARTMonTools,
some years back. Since (I think) MacOS X.3, the API to do an
ATAIdentify has been in there.
You just need to create a plug-in interface to
kIOATASMARTUserClientTypeID, query the plug-in to get a handle to the
interface. Then send the Identify command.
From ATASMARTLib.h ;
/*!
@function GetATAIdentifyData
@abstract Reads the 512-byte data provided by the drive in response
to the ATA IDENTIFY DEVICE command.
@discussion Reads the 512-byte data provided by the drive in response
to the ATA IDENTIFY DEVICE command.
See section 8.15 of ATA/ATAPI-6.
The data placed in buffer is guaranteed to be in native endian form
on return.
(i.e. it will be byte swapped on big endian platforms, so the
caller need not
do anything)
@param interface A valid IOATASMARTInterface**.
@param buffer A valid buffer.
@param inSize The number of bytes to place in the buffer.
@param outSize The number of bytes placed in the buffer. Can be
NULL if the information
is not required by the caller.
@return An IOReturn result code. If inSize is greater than 512 or
less than 1,
kIOReturnBadArgument is returned.
*/
IOReturn ( *GetATAIdentifyData ) ( void * interface,
void * buffer,
UInt32 inSize,
UInt32 * outSize );
I have some working dummy-code which does just this. Let me know if
you want it. It's ancient but I built it on 10.4.6/ppc and it's fine.
Here's a chunk of the Ident, including the s/n;
GetATAIdentifyData myErr = 0
0x00000000 - 04 5A 3F FF C8 37 00 10 00 00 00 00 00 3F 00 00 .Z?..
7.......?..
0x00000010 - 00 00 00 00 20 20 20 20 20 20 4D 52 47 34 32
36 .... MRG426
0x00000020 - 4B 34 48 35 42 4A 47 48 00 03 3D 98 00 04 4D 4F
K4H5BJGH..=...MO
0x00000030 - 34 41 41 44 37 41 48 69 74 61 63 68 69 20 49 43
4AAD7AHitachi IC
0x00000040 - 32 35 4E 30 38 30 41 54 4D 52 30 34 2D 30 20 20
25N080ATMR04-0
Regards,
Pete C
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden