Can anyone explain the core difference between HDIO_GETGEO and HDIO_GET_IDENTITY?
From the Linux documentation and this document titled: Summary of HDIO_ ioctl calls., I know that the former is for "getting device geometries" and the latter for "getting IDE identification info".
In the HDIO summary document, it is said that the object of "struct hd_geometry" is passed as an argument to a "ioctl" call and it will contain the "number of sectors".
However, HDIO_GET_IDENTITY returns an unsigned char array. But from this SO question, I hope that struct hd_driveid contains the bytes per sector and other info. And I read somewhere that hd_driveid can be passed as an argument to ioctl if HDIO_GET_IDNTITY is used in the call.
I need a clarification for all these doubts..
Also which HDIO_ ioctl call should I use to get the number of sectors and bytes per sector of my hard disk in Linux?
/sys/block/sda/sizeand/sys/block/sda/queue/hw_sector_size. The former gives the size as a multiple of 512 bytes ( regardless of sector size of the drive ), and the latter gives the real sector size of the drive. If you want the logical sector size instead, uselogical_block_sizeinstead.