linux/ataidle.c
// send a command to the drive
send a command to the drive
send a command to the drive
int32_t
ata_cmd(struct ATA *ata, int ata_chan, int ata_dev, int cmd, int drivercmd)
{
	int32_t rc = 0;
	int fd = 0;
	int chan = ata_chan * 2;
	int devnum = chan + ata_dev;
	char devchar = 'a' + devnum;
	char device[20];
	sprintf(device, "/dev/hd%c", devchar);
	fd = open(device, O_RDONLY);
	if( fd < 0 )
		rc = -1;
	if(!rc) {
		ata->atacmd.cmd = cmd;
		rc = ioctl( fd, HDIO_DRIVE_CMD, &ata->atacmd );
		close(fd);
	}
	return rc;
}
int32_t ata_cmd ( struct ATA * ata , int ata_chan , int ata_dev , int cmd , int drivercmd ) { int32_t rc = 0 ; int fd = 0 ; int chan = ata_chan * 2 ; int devnum = chan + ata_dev ; char devchar = ' ' + devnum ; char device [ 20 ] ; sprintf ( device , " " , devchar ) ; fd = open ( device , O_RDONLY ) ; if ( fd < 0 ) rc = -1 ; if ( ! rc ) { ata -> atacmd . cmd = cmd ; rc = ioctl ( fd , HDIO_DRIVE_CMD , & ata -> atacmd ) ; close ( fd ) ; } return rc ; }
send a command to the drive
send a command to the drive