Sample Header Ad - 728x90

ioctl: invalid argument for HDIO_GET_IDENTITY

4 votes
1 answer
3206 views
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: 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). Result of hdparm -i /dev/sda is SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 c0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 HDIO_GET_IDENTITY failed: Invalid argument
Asked by gangadhars (727 rep)
Apr 18, 2014, 06:18 AM
Last activity: Jun 19, 2025, 06:09 PM