The values of sector/track/cylinder are an ancient remnant from when the controller had to know these values. All modern drives are LBA (Logical Block Addressing) simply numbered 0…N.
The H/T/C numbers that EIDE drives display are artificial and usually have no relation to the actual internal H/T/C numbers. In the case of a solid state drive or CF card, they are of course completely artificial as there are no heads, tracks or cylinders. In some cases the BIOS still needs to know these numbers.
I mention this because I haven’t seen any access to these numbers in QNX 6. There might be an API the will provide them, but as I’ve tried to say they are unnecessary.
On the other hand, you can open your device:
fd = open("/dev/hd0", O_RDONLY);
and then use stat(fd, …). If you poke around in the stat structure you will find the number you seek.
As machoen pointed out, multiplying cylindersheadssectors (CHS) is not accurate for modern drives. The drive typcically contains MORE sectors than this computation.
Executing fstat on /dev/hd0, Total blocks = 160836480
This number is obtained by “asking” the drive interface for the number of LBAs (sectors) it supports. Part of the ATAPI spec.
160826652(Added all partition blocks together)
This is the result of CHS-63… (1001125563 - 63) The remaining sectors (9828) are “round-off” and can’t be put in the partition table - hence they are essentially unusable.
sector number and block number. Are they same or different ?
In traditional unix, “block” was 1K while “sector” was 512b. However in QNX, a block is 512b - so block is the same as sector.
The concept of “block” being an integral number of sectors is analogous to “cluster” in the MS world.