(unknown)
Hi, I want get the information from the hard drive via ioctl command. I want to use the HDIO_DRIVE _TASK command not the HDIO_DRIVE_CMD. With the HDIO_DRIVE _TASK the function returns 0 thats ok, but no data is in the additional 512 unsigned char array. Here is the code:
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/hdreg.h>
#define SIZE 520
int main ()
{
int fd, i; unsigned char args[SIZE]; for (i = 0; i < SIZE; i++) args[i] = 0;
// prerequisites DRDY set to 1
args[0] = 0xEC; //COMMAND
//args[1] = 0xD0; //FEATURE
//args[2] = 0x1; //NSECTOR
//args[3] = 0x1; //SECTOR //args[4] = 0x4F; //LCYL //args[5] = 0xC2; //HCYL //args[6] = 64; //SELECT args[7] = 0xff;
fd = open ("/dev/hda", O_RDONLY);
printf ("%d\n", ioctl (fd, HDIO_DRIVE_TASK, &args));
for (i = 0; i < SIZE; i++)
{
if (i == 7)
puts ("\ndata:");
printf ("%X|", args[i]);
}
close (fd);
puts ("");
return (0);
}____________________________________________________________________________________
Got a little couch potato?
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz