I need to get the hard drive specifications on Win and * nix machines. I used <hdreg.h> for Linux as follows:
static struct hd_driveid hd; int device; if ((device = open("/dev/sda", O_RDONLY | O_NONBLOCK)) < 0) { cerr << "ERROR: Cannot open device /dev/sda \n"; exit(1); } if (!ioctl(device, HDIO_GET_IDENTITY, &hd)) { cout << hd.model << endl; cout << hd.serial_no << endl; cout << hd.heads << endl; }
I need hd_driveid tell me more disk information. I want to know:
- Number of sections
- The characteristics of each section (format, label, flags, size, starting point, number of tracks, etc.).
- Number of tracks per cylinder
- Number of shared tracks
- Max block size
- Minimum block size
- Default block size
- Total device size
My questions:
- Is there a general (platform independent) way to connect the equipment? I would like to use the same code for win and * nix. (even if there was no other way than embedding assembly code in cpp)
- If this does not happen, how do I get information in * nix?
c ++ linux hardware hard-drive
sorush-r
source share