I need to get specifications of hard disk on both Win and *nix machines. I used
on Linux like this:
static struct hd_driveid hd;
Nearly everything in your list has nothing to do with "specifications of hard disk":
hd_driveid.sector_bytes
(usually 512, but some modern drives use 4096). I'm not aware of a maximum "block size", which is a property of the filesystem. I'm also not sure why this is useful.The total size in sectors is in hd_driveid.lba_capacity_2
. Additionally, the size in bytes can probably be obtained with something like
#define _FILE_OFFSET_BITS 64
#include
#include
...
off_t size_in_bytes = lseek(device, 0, SEEK_END);
if (size_in_bytes == (off_t)-1) { ... error, error code in ERRNO ... }
Note that in both cases, it'll probably be a few megabytes bigger than sizes calculated by C×H×S.
It might help if you told us why you wanted this information...