linux/ataidle.c
// return the maximum valid channel id
return the maximum valid channel id
return the maximum valid channel id
int32_t 
ata_getmaxchan(struct ATA *ata, uint32_t *maxchan)
{
	int rc = 0, fd = 0, ndevs = 0;
	char devname[15];
	bool done = false;
	while(!done && (ndevs < 26)) {
		memset(devname, 0, 15);
		snprintf(devname, 15, "/dev/hd%c", 'a'+ndevs);
		fd = open(devname, O_RDONLY);
		if(fd < 0) {
			done = true;
		} else {
			close(fd);
			ndevs++;
		}
	}
	double devs = (double) ndevs;
	*maxchan = ceil(devs/2);
	*maxchan = 8;
	return rc;
}
int32_t ata_getmaxchan ( struct ATA * ata , uint32_t * maxchan ) { int rc = 0 , fd = 0 , ndevs = 0 ; char devname [ 15 ] ; bool done = false ; while ( ! done && ( ndevs < 26 ) ) { memset ( devname , 0 , 15 ) ; snprintf ( devname , 15 , " " , ' ' + ndevs ) ; fd = open ( devname , O_RDONLY ) ; if ( fd < 0 ) { done = true ; } else { close ( fd ) ; ndevs ++ ; } } double devs = ( double ) ndevs ; * maxchan = ceil ( devs / 2 ) ; * maxchan = 8 ; return rc ; }
return the maximum valid channel id
return the maximum valid channel id
// keep trying to open hdX (a-z), stop when an open fails.