From c822610d8f077afbca293cd4ca98434e68602629 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 27 Jan 2003 07:58:18 +0000 Subject: Implement MDIOCLIST which returns the unit numbers of configured md(4) devices. We use the md_pad[] array and if there are more units than its size the last returned unit number will be -1, but the number of units returned is correct. --- sys/dev/md/md.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'sys') diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 4befee3..f405b62 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -1133,6 +1133,7 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) { struct md_ioctl *mdio; struct md_s *sc; + int i; if (md_debug) printf("mdctlioctl(%s %lx %p %x %p)\n", @@ -1195,6 +1196,16 @@ mdctlioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td) break; } return (0); + case MDIOCLIST: + i = 1; + LIST_FOREACH(sc, &md_softc_list, list) { + if (i == MDNPAD - 1) + mdio->md_pad[i] = -1; + else + mdio->md_pad[i++] = sc->unit; + } + mdio->md_pad[0] = i - 1; + return (0); default: return (ENOIOCTL); }; -- cgit v1.1