- Add a new ioctl to get the maximum number of ATA channels.

- Use it in atacontrol(8) when listing ATA devices instead of
  stopping at the first ENXIO received.

This makes atacontrol list work on my sparc64 where the two ATA
channels I have are numbered 2 and 3.

Reviewed by:	sos
This commit is contained in:
Maxime Henrion 2003-03-22 12:18:20 +00:00
parent 66996f7a88
commit 0a50de79cb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112494
3 changed files with 14 additions and 4 deletions

View File

@ -249,7 +249,7 @@ int
main(int argc, char **argv)
{
struct ata_cmd iocmd;
int fd;
int fd, maxunit, unit;
if ((fd = open("/dev/ata", O_RDWR)) < 0)
err(1, "control device not found");
@ -278,9 +278,12 @@ main(int argc, char **argv)
}
if (!strcmp(argv[1], "list") && argc == 2) {
int unit = 0;
while (info_print(fd, unit++, 1) != ENXIO);
iocmd.cmd = ATAGMAXCHANNEL;
if (ioctl(fd, IOCATA, &iocmd) < 0)
err(1, "ioctl(ATAGMAXCHANNEL)");
maxunit = iocmd.u.maxchan;
for (unit = 0; unit < maxunit; unit++)
info_print(fd, unit, 1);
}
else if (!strcmp(argv[1], "info") && argc == 3) {
info_print(fd, iocmd.channel, 0);

View File

@ -304,6 +304,11 @@ ataioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, struct thread *td)
if (cmd != IOCATA)
return ENOTTY;
if (iocmd->cmd == ATAGMAXCHANNEL) {
iocmd->u.maxchan = devclass_get_maxunit(ata_devclass);
return 0;
}
if (iocmd->channel < -1 || iocmd->device < -1 || iocmd->device > SLAVE)
return ENXIO;

View File

@ -369,6 +369,7 @@ struct ata_cmd {
#define ATARAIDDELETE 10
#define ATARAIDSTATUS 11
#define ATAENCSTAT 12
#define ATAGMAXCHANNEL 13
union {
struct {
@ -421,6 +422,7 @@ struct ata_cmd {
int error;
char sense_data[18];
} atapi;
int maxchan;
} u;
};