Coding question: finding the size of a block device

Frank Mitchell mitchell at cloudynwuk.force9.co.uk
Sat Jun 24 16:30:22 UTC 2006


Let's assume your Block Device is an ATA Hard Disk and you're using FreeBSD
6.0 like me.

Take a look at <sys/ata.h> and you'll see a large fully-commented structure,
"struct ata_params", which is used to return the information from the ATA
"IDENTIFY DEVICE" command using something like:
"ioctl(DevFil,IOCATAGPARM,&Parms);"

This probably tells you everything you need. Plus IOCATAGPARM also returns
CD/DVD Drive information using the related IDENTIFY PACKET DEVICE command.

For further details consult the T13 Website. For ATA/ATAPI you might start
with: "T13 1153D Revision 18" "Information Technology - AT Attachment with
Packet Interface Extension (ATA/ATAPI-4)". Though there are later versions:
"T13 1321D" (ATA/ATAPI-5) and "T13 1410D" (ATA/ATAPI-6).

Whatever device you have there's probably some Hardware Command which gives
you all the technical details.

Faictz Ce Que Vouldras: Frank Mitchell





-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.3/374 - Release Date: 23/06/2006



More information about the freebsd-hackers mailing list