Getting ATA drive capacity on all buses from identity data

4 views
Skip to first unread message

Mike

unread,
Jan 13, 2011, 7:31:54 PM1/13/11
to ata-sc...@lists.apple.com
I am sure this has been asked somewhere many times but I didn't see it
in the archives, so I'm asking it here.

How does one get the device capacity for ATA/SATA storage devices
regardless of bus type? I looked at the SMART sample which shows how to
get some of the identity data, but it's not clear how to get the device
capacity using code similar to the sample code.

Thanks,

-m
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Ata-scsi-dev mailing list (Ata-sc...@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/ata-scsi-dev/ata-scsi-dev-garchive-72467%40googlegroups.com

This email sent to ata-scsi-dev-...@googlegroups.com

Chris Sarcone

unread,
Jan 13, 2011, 8:09:08 PM1/13/11
to junk...@michael-amorose.com, ata-sc...@lists.apple.com
Mike --

I am sure this has been asked somewhere many times but I didn't see it in the archives, so I'm asking it here.

How does one get the device capacity for ATA/SATA storage devices regardless of bus type? I looked at the SMART sample which shows how to get some of the identity data, but it's not clear how to get the device capacity using code similar to the sample code.

For all disks (SATA or SCSI) you can simply get the size of the BSD node that represents the whole disk in the IORegistry.

IOServiceGetMatchingService ( IOBSDNameMatching ( "disk0" ) );
IORegistryEntrySearchCFProperty() with a property of "Size".

-- Chris

------------------

6 Infinite Loop

M/S 306-2MS

Cupertino CA 95014

phone: (408) 974-4033

fax:   (408) 862-7577

email: sar...@apple.com


Reply all
Reply to author
Forward
0 new messages