I wrote a program to get the details of hard disk drive using HDIO_ ioctl calls
.
For writing program, I'm referring Documentation/ioctl/hdio.txt
in kernel source(2.6.32).
Here is my main part of code:
unsigned char driveid[512];
fd = open("/dev/sda", O_RDONLY); // validated fd.
retval = ioctl(fd, HDIO_GET_IDENTITY, &driveid);
if(retval < 0) {
perror("ioctl(HDIO_GET_IDENTITY)");
exit(3);
}
When I run(as root) the above code, I got below error:
ioctl(HDIO_GET_IDENTITY): Invalid argument
What is the wrong in the program? Why I'm getting error?
Additional Info: OS: CentOS-6.5
, kernel version: 2.6.32
, IA:x86_64
(running on VMware).