diff options
author | mux <mux@FreeBSD.org> | 2003-03-22 12:18:20 +0000 |
---|---|---|
committer | mux <mux@FreeBSD.org> | 2003-03-22 12:18:20 +0000 |
commit | 41824db1c60239f31a899ab05c9bdc7cbf728bd0 (patch) | |
tree | bf4321914b31ede56d450445be309e2854f4c107 /sbin/atacontrol/atacontrol.c | |
parent | 6aa08c7dda5a26d5cffef6924435fc620e970d5b (diff) | |
download | FreeBSD-src-41824db1c60239f31a899ab05c9bdc7cbf728bd0.zip FreeBSD-src-41824db1c60239f31a899ab05c9bdc7cbf728bd0.tar.gz |
- 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
Diffstat (limited to 'sbin/atacontrol/atacontrol.c')
-rw-r--r-- | sbin/atacontrol/atacontrol.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/sbin/atacontrol/atacontrol.c b/sbin/atacontrol/atacontrol.c index d7b6995..c55e399 100644 --- a/sbin/atacontrol/atacontrol.c +++ b/sbin/atacontrol/atacontrol.c @@ -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); |