freebsd/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 chan, int dev, int atacmd, int drivercmd)
{
	int32_t rc = 0;
	if(!ata_devpresent( ata, chan, dev ) && (drivercmd != ATAGMAXCHANNEL)) {
		rc = -1;
	}
	if(!rc) {
		ata->atacmd.channel = chan;
		ata->atacmd.device = dev;
		if(drivercmd != 0)
			ata->atacmd.cmd = drivercmd;
		else {
			ata->atacmd.cmd = ATAREQUEST;
		}
		ata->atacmd.u.request.u.ata.command = atacmd;
		rc = ioctl( ata->fd, IOCATA, &(ata->atacmd) );
	}
	return rc;
}
int32_t ata_cmd ( struct ATA * ata , int chan , int dev , int atacmd , int drivercmd ) { int32_t rc = 0 ; if ( ! ata_devpresent ( ata , chan , dev ) && ( drivercmd != ATAGMAXCHANNEL ) ) { rc = -1 ; } if ( ! rc ) { ata -> atacmd . channel = chan ; ata -> atacmd . device = dev ; if ( drivercmd != 0 ) ata -> atacmd . cmd = drivercmd ; else { ata -> atacmd . cmd = ATAREQUEST ; } ata -> atacmd . u . request . u . ata . command = atacmd ; rc = ioctl ( ata -> fd , IOCATA , & ( ata -> atacmd ) ) ; } return rc ; }
send a command to the drive
send a command to the drive
// check that the device actually exists, first // if it does exist, send the command