2 * Copyright (c) 2002 Poul-Henning Kamp
3 * Copyright (c) 2002 Networks Associates Technology, Inc.
6 * This software was developed for the FreeBSD Project by Poul-Henning Kamp
7 * and NAI Labs, the Security Research Division of Network Associates, Inc.
8 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the
9 * DARPA CHATS research program.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 3. The names of the authors may not be used to endorse or promote
20 * products derived from this software without specific prior written
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD$");
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/kernel.h>
44 #include <sys/sysctl.h>
46 #include <sys/ctype.h>
47 #include <sys/fcntl.h>
48 #include <sys/malloc.h>
50 #include <sys/devicestat.h>
51 #include <machine/md_var.h>
54 #include <sys/mutex.h>
55 #include <geom/geom.h>
56 #include <geom/geom_disk.h>
57 #include <geom/geom_int.h>
59 #include <dev/led/led.h>
61 #include <machine/bus.h>
66 struct sysctl_ctx_list sysctl_ctx;
67 struct sysctl_oid *sysctl_tree;
73 static g_access_t g_disk_access;
74 static g_start_t g_disk_start;
75 static g_ioctl_t g_disk_ioctl;
76 static g_dumpconf_t g_disk_dumpconf;
77 static g_provgone_t g_disk_providergone;
79 static struct g_class g_disk_class = {
80 .name = G_DISK_CLASS_NAME,
82 .start = g_disk_start,
83 .access = g_disk_access,
84 .ioctl = g_disk_ioctl,
85 .providergone = g_disk_providergone,
86 .dumpconf = g_disk_dumpconf,
89 SYSCTL_DECL(_kern_geom);
90 static SYSCTL_NODE(_kern_geom, OID_AUTO, disk, CTLFLAG_RW, 0,
93 DECLARE_GEOM_CLASS(g_disk_class, g_disk);
96 g_disk_access(struct g_provider *pp, int r, int w, int e)
99 struct g_disk_softc *sc;
102 g_trace(G_T_ACCESS, "g_disk_access(%s, %d, %d, %d)",
106 if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
108 * Allow decreasing access count even if disk is not
111 if (r <= 0 && w <= 0 && e <= 0)
119 if ((pp->acr + pp->acw + pp->ace) == 0 && (r + w + e) > 0) {
120 if (dp->d_open != NULL) {
121 error = dp->d_open(dp);
122 if (bootverbose && error != 0)
123 printf("Opened disk %s -> %d\n",
128 pp->mediasize = dp->d_mediasize;
129 pp->sectorsize = dp->d_sectorsize;
130 if (dp->d_maxsize == 0) {
131 printf("WARNING: Disk drive %s%d has no d_maxsize\n",
132 dp->d_name, dp->d_unit);
133 dp->d_maxsize = DFLTPHYS;
135 if (dp->d_delmaxsize == 0) {
136 if (bootverbose && dp->d_flags & DISKFLAG_CANDELETE) {
137 printf("WARNING: Disk drive %s%d has no "
138 "d_delmaxsize\n", dp->d_name, dp->d_unit);
140 dp->d_delmaxsize = dp->d_maxsize;
142 pp->stripeoffset = dp->d_stripeoffset;
143 pp->stripesize = dp->d_stripesize;
144 dp->d_flags |= DISKFLAG_OPEN;
145 } else if ((pp->acr + pp->acw + pp->ace) > 0 && (r + w + e) == 0) {
146 if (dp->d_close != NULL) {
147 error = dp->d_close(dp);
149 printf("Closed disk %s -> %d\n",
152 sc->state = G_STATE_ACTIVE;
154 led_set(sc->led, "0");
155 dp->d_flags &= ~DISKFLAG_OPEN;
161 g_disk_kerneldump(struct bio *bp, struct disk *dp)
163 struct g_kerneldump *gkd;
166 gkd = (struct g_kerneldump*)bp->bio_data;
167 gp = bp->bio_to->geom;
168 g_trace(G_T_TOPOLOGY, "g_disk_kerneldump(%s, %jd, %jd)",
169 gp->name, (intmax_t)gkd->offset, (intmax_t)gkd->length);
170 if (dp->d_dump == NULL) {
171 g_io_deliver(bp, ENODEV);
174 gkd->di.dumper = dp->d_dump;
176 gkd->di.blocksize = dp->d_sectorsize;
177 gkd->di.maxiosize = dp->d_maxsize;
178 gkd->di.mediaoffset = gkd->offset;
179 if ((gkd->offset + gkd->length) > dp->d_mediasize)
180 gkd->length = dp->d_mediasize - gkd->offset;
181 gkd->di.mediasize = gkd->length;
186 g_disk_setstate(struct bio *bp, struct g_disk_softc *sc)
190 memcpy(&sc->state, bp->bio_data, sizeof(sc->state));
191 if (sc->led[0] != 0) {
196 case G_STATE_REBUILD:
206 led_set(sc->led, cmd);
212 g_disk_done(struct bio *bp)
216 struct g_disk_softc *sc;
218 /* See "notes" for why we need a mutex here */
219 /* XXX: will witness accept a mix of Giant/unGiant drivers here ? */
220 bp2 = bp->bio_parent;
221 sc = bp2->bio_to->private;
222 bp->bio_completed = bp->bio_length - bp->bio_resid;
224 mtx_lock(&sc->done_mtx);
225 if (bp2->bio_error == 0)
226 bp2->bio_error = bp->bio_error;
227 bp2->bio_completed += bp->bio_completed;
228 if ((bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_DELETE|BIO_FLUSH)) != 0)
229 devstat_end_transaction_bio_bt(sc->dp->d_devstat, bp, &now);
231 if (bp2->bio_children == bp2->bio_inbed) {
232 mtx_unlock(&sc->done_mtx);
233 bp2->bio_resid = bp2->bio_bcount - bp2->bio_completed;
234 g_io_deliver(bp2, bp2->bio_error);
236 mtx_unlock(&sc->done_mtx);
241 g_disk_ioctl(struct g_provider *pp, u_long cmd, void * data, int fflag, struct thread *td)
244 struct g_disk_softc *sc;
250 if (dp->d_ioctl == NULL)
252 error = dp->d_ioctl(dp, cmd, data, fflag, td);
257 g_disk_maxsize(struct disk *dp, struct bio *bp)
259 if (bp->bio_cmd == BIO_DELETE)
260 return (dp->d_delmaxsize);
261 return (dp->d_maxsize);
265 g_disk_maxsegs(struct disk *dp, struct bio *bp)
267 return ((g_disk_maxsize(dp, bp) / PAGE_SIZE) + 1);
271 g_disk_advance(struct disk *dp, struct bio *bp, off_t off)
274 bp->bio_offset += off;
275 bp->bio_length -= off;
277 if ((bp->bio_flags & BIO_VLIST) != 0) {
278 bus_dma_segment_t *seg, *end;
280 seg = (bus_dma_segment_t *)bp->bio_data;
281 end = (bus_dma_segment_t *)bp->bio_data + bp->bio_ma_n;
282 off += bp->bio_ma_offset;
283 while (off >= seg->ds_len) {
284 KASSERT((seg != end),
285 ("vlist request runs off the end"));
289 bp->bio_ma_offset = off;
290 bp->bio_ma_n = end - seg;
291 bp->bio_data = (void *)seg;
292 } else if ((bp->bio_flags & BIO_UNMAPPED) != 0) {
293 bp->bio_ma += off / PAGE_SIZE;
294 bp->bio_ma_offset += off;
295 bp->bio_ma_offset %= PAGE_SIZE;
296 bp->bio_ma_n -= off / PAGE_SIZE;
303 g_disk_seg_limit(bus_dma_segment_t *seg, off_t *poffset,
304 off_t *plength, int *ppages)
306 uintptr_t seg_page_base;
307 uintptr_t seg_page_end;
315 if (length > seg->ds_len - offset)
316 length = seg->ds_len - offset;
318 seg_page_base = trunc_page(seg->ds_addr + offset);
319 seg_page_end = round_page(seg->ds_addr + offset + length);
320 seg_pages = (seg_page_end - seg_page_base) >> PAGE_SHIFT;
322 if (seg_pages > *ppages) {
324 length = (seg_page_base + (seg_pages << PAGE_SHIFT)) -
325 (seg->ds_addr + offset);
330 *ppages -= seg_pages;
334 g_disk_vlist_limit(struct disk *dp, struct bio *bp, bus_dma_segment_t **pendseg)
336 bus_dma_segment_t *seg, *end;
341 seg = (bus_dma_segment_t *)bp->bio_data;
342 end = (bus_dma_segment_t *)bp->bio_data + bp->bio_ma_n;
343 residual = bp->bio_length;
344 offset = bp->bio_ma_offset;
345 pages = g_disk_maxsegs(dp, bp);
346 while (residual != 0 && pages != 0) {
347 KASSERT((seg != end),
348 ("vlist limit runs off the end"));
349 g_disk_seg_limit(seg, &offset, &residual, &pages);
358 g_disk_limit(struct disk *dp, struct bio *bp)
360 bool limited = false;
363 maxsz = g_disk_maxsize(dp, bp);
366 * XXX: If we have a stripesize we should really use it here.
367 * Care should be taken in the delete case if this is done
368 * as deletes can be very sensitive to size given how they
371 if (bp->bio_length > maxsz) {
372 bp->bio_length = maxsz;
376 if ((bp->bio_flags & BIO_VLIST) != 0) {
377 bus_dma_segment_t *firstseg, *endseg;
380 firstseg = (bus_dma_segment_t*)bp->bio_data;
381 residual = g_disk_vlist_limit(dp, bp, &endseg);
383 bp->bio_ma_n = endseg - firstseg;
384 bp->bio_length -= residual;
387 } else if ((bp->bio_flags & BIO_UNMAPPED) != 0) {
389 howmany(bp->bio_ma_offset + bp->bio_length, PAGE_SIZE);
396 g_disk_start(struct bio *bp)
398 struct bio *bp2, *bp3;
400 struct g_disk_softc *sc;
404 sc = bp->bio_to->private;
405 if (sc == NULL || (dp = sc->dp) == NULL || dp->d_destroyed) {
406 g_io_deliver(bp, ENXIO);
410 switch(bp->bio_cmd) {
412 if (!(dp->d_flags & DISKFLAG_CANDELETE)) {
419 KASSERT((dp->d_flags & DISKFLAG_UNMAPPED_BIO) != 0 ||
420 (bp->bio_flags & BIO_UNMAPPED) == 0,
421 ("unmapped bio not supported by disk %s", dp->d_name));
424 bp2 = g_clone_bio(bp);
430 if (g_disk_limit(dp, bp2)) {
431 off += bp2->bio_length;
434 * To avoid a race, we need to grab the next bio
435 * before we schedule this one. See "notes".
437 bp3 = g_clone_bio(bp);
439 bp->bio_error = ENOMEM;
441 bp2->bio_done = g_disk_done;
442 bp2->bio_pblkno = bp2->bio_offset / dp->d_sectorsize;
443 bp2->bio_bcount = bp2->bio_length;
445 mtx_lock(&sc->start_mtx);
446 devstat_start_transaction_bio(dp->d_devstat, bp2);
447 mtx_unlock(&sc->start_mtx);
455 g_disk_advance(dp, bp2, off);
459 /* Give the driver a chance to override */
460 if (dp->d_getattr != NULL) {
461 if (bp->bio_disk == NULL)
463 error = dp->d_getattr(bp);
468 if (g_handleattr_int(bp, "GEOM::candelete",
469 (dp->d_flags & DISKFLAG_CANDELETE) != 0))
471 else if (g_handleattr_int(bp, "GEOM::fwsectors",
474 else if (g_handleattr_int(bp, "GEOM::fwheads", dp->d_fwheads))
476 else if (g_handleattr_off_t(bp, "GEOM::frontstuff", 0))
478 else if (g_handleattr_str(bp, "GEOM::ident", dp->d_ident))
480 else if (g_handleattr_uint16_t(bp, "GEOM::hba_vendor",
483 else if (g_handleattr_uint16_t(bp, "GEOM::hba_device",
486 else if (g_handleattr_uint16_t(bp, "GEOM::hba_subvendor",
487 dp->d_hba_subvendor))
489 else if (g_handleattr_uint16_t(bp, "GEOM::hba_subdevice",
490 dp->d_hba_subdevice))
492 else if (!strcmp(bp->bio_attribute, "GEOM::kerneldump"))
493 g_disk_kerneldump(bp, dp);
494 else if (!strcmp(bp->bio_attribute, "GEOM::setstate"))
495 g_disk_setstate(bp, sc);
496 else if (g_handleattr_uint16_t(bp, "GEOM::rotation_rate",
497 dp->d_rotation_rate))
503 g_trace(G_T_BIO, "g_disk_flushcache(%s)",
505 if (!(dp->d_flags & DISKFLAG_CANFLUSHCACHE)) {
509 bp2 = g_clone_bio(bp);
511 g_io_deliver(bp, ENOMEM);
514 bp2->bio_done = g_disk_done;
516 mtx_lock(&sc->start_mtx);
517 devstat_start_transaction_bio(dp->d_devstat, bp2);
518 mtx_unlock(&sc->start_mtx);
525 if (error != EJUSTRETURN)
526 g_io_deliver(bp, error);
531 g_disk_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_consumer *cp, struct g_provider *pp)
535 struct g_disk_softc *sc;
540 if (sc == NULL || (dp = sc->dp) == NULL)
542 if (indent == NULL) {
543 sbuf_printf(sb, " hd %u", dp->d_fwheads);
544 sbuf_printf(sb, " sc %u", dp->d_fwsectors);
548 sbuf_printf(sb, "%s<fwheads>%u</fwheads>\n",
549 indent, dp->d_fwheads);
550 sbuf_printf(sb, "%s<fwsectors>%u</fwsectors>\n",
551 indent, dp->d_fwsectors);
552 if (dp->d_getattr != NULL) {
553 buf = g_malloc(DISK_IDENT_SIZE, M_WAITOK);
556 bp->bio_attribute = "GEOM::ident";
557 bp->bio_length = DISK_IDENT_SIZE;
559 res = dp->d_getattr(bp);
560 sbuf_printf(sb, "%s<ident>", indent);
561 g_conf_printf_escaped(sb, "%s",
562 res == 0 ? buf: dp->d_ident);
563 sbuf_printf(sb, "</ident>\n");
564 bp->bio_attribute = "GEOM::lunid";
565 bp->bio_length = DISK_IDENT_SIZE;
567 if (dp->d_getattr(bp) == 0) {
568 sbuf_printf(sb, "%s<lunid>", indent);
569 g_conf_printf_escaped(sb, "%s", buf);
570 sbuf_printf(sb, "</lunid>\n");
572 bp->bio_attribute = "GEOM::lunname";
573 bp->bio_length = DISK_IDENT_SIZE;
575 if (dp->d_getattr(bp) == 0) {
576 sbuf_printf(sb, "%s<lunname>", indent);
577 g_conf_printf_escaped(sb, "%s", buf);
578 sbuf_printf(sb, "</lunname>\n");
583 sbuf_printf(sb, "%s<ident>", indent);
584 g_conf_printf_escaped(sb, "%s", dp->d_ident);
585 sbuf_printf(sb, "</ident>\n");
587 sbuf_printf(sb, "%s<descr>", indent);
588 g_conf_printf_escaped(sb, "%s", dp->d_descr);
589 sbuf_printf(sb, "</descr>\n");
594 g_disk_resize(void *ptr, int flag)
598 struct g_provider *pp;
600 if (flag == EV_CANCEL)
607 if (dp->d_destroyed || gp == NULL)
610 LIST_FOREACH(pp, &gp->provider, provider) {
611 if (pp->sectorsize != 0 &&
612 pp->sectorsize != dp->d_sectorsize)
613 g_wither_provider(pp, ENXIO);
615 g_resize_provider(pp, dp->d_mediasize);
620 g_disk_create(void *arg, int flag)
623 struct g_provider *pp;
625 struct g_disk_softc *sc;
628 if (flag == EV_CANCEL)
632 sc = g_malloc(sizeof(*sc), M_WAITOK | M_ZERO);
633 mtx_init(&sc->start_mtx, "g_disk_start", NULL, MTX_DEF);
634 mtx_init(&sc->done_mtx, "g_disk_done", NULL, MTX_DEF);
636 gp = g_new_geomf(&g_disk_class, "%s%d", dp->d_name, dp->d_unit);
638 pp = g_new_providerf(gp, "%s", gp->name);
639 devstat_remove_entry(pp->stat);
641 dp->d_devstat->id = pp;
642 pp->mediasize = dp->d_mediasize;
643 pp->sectorsize = dp->d_sectorsize;
644 pp->stripeoffset = dp->d_stripeoffset;
645 pp->stripesize = dp->d_stripesize;
646 if ((dp->d_flags & DISKFLAG_UNMAPPED_BIO) != 0)
647 pp->flags |= G_PF_ACCEPT_UNMAPPED;
648 if ((dp->d_flags & DISKFLAG_DIRECT_COMPLETION) != 0)
649 pp->flags |= G_PF_DIRECT_SEND;
650 pp->flags |= G_PF_DIRECT_RECEIVE;
652 printf("GEOM: new disk %s\n", gp->name);
653 sysctl_ctx_init(&sc->sysctl_ctx);
654 snprintf(tmpstr, sizeof(tmpstr), "GEOM disk %s", gp->name);
655 sc->sysctl_tree = SYSCTL_ADD_NODE(&sc->sysctl_ctx,
656 SYSCTL_STATIC_CHILDREN(_kern_geom_disk), OID_AUTO, gp->name,
657 CTLFLAG_RD, 0, tmpstr);
658 if (sc->sysctl_tree != NULL) {
659 SYSCTL_ADD_STRING(&sc->sysctl_ctx,
660 SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "led",
661 CTLFLAG_RWTUN, sc->led, sizeof(sc->led),
666 g_error_provider(pp, 0);
670 * We get this callback after all of the consumers have gone away, and just
671 * before the provider is freed. If the disk driver provided a d_gone
672 * callback, let them know that it is okay to free resources -- they won't
673 * be getting any more accesses from GEOM.
676 g_disk_providergone(struct g_provider *pp)
679 struct g_disk_softc *sc;
681 sc = (struct g_disk_softc *)pp->private;
683 if (dp != NULL && dp->d_gone != NULL)
685 if (sc->sysctl_tree != NULL) {
686 sysctl_ctx_free(&sc->sysctl_ctx);
687 sc->sysctl_tree = NULL;
689 if (sc->led[0] != 0) {
690 led_set(sc->led, "0");
694 pp->geom->softc = NULL;
695 mtx_destroy(&sc->done_mtx);
696 mtx_destroy(&sc->start_mtx);
701 g_disk_destroy(void *ptr, int flag)
705 struct g_disk_softc *sc;
715 g_wither_geom(gp, ENXIO);
721 * We only allow printable characters in disk ident,
722 * the rest is converted to 'x<HH>'.
725 g_disk_ident_adjust(char *ident, size_t size)
727 char *p, tmp[4], newid[DISK_IDENT_SIZE];
730 for (p = ident; *p != '\0'; p++) {
735 snprintf(tmp, sizeof(tmp), "x%02hhx",
736 *(unsigned char *)p);
738 if (strlcat(newid, tmp, sizeof(newid)) >= sizeof(newid))
742 strlcpy(ident, newid, size);
749 return (g_malloc(sizeof(struct disk), M_WAITOK | M_ZERO));
753 disk_create(struct disk *dp, int version)
756 if (version != DISK_VERSION) {
757 printf("WARNING: Attempt to add disk %s%d %s",
758 dp->d_name, dp->d_unit,
759 " using incompatible ABI version of disk(9)\n");
760 printf("WARNING: Ignoring disk %s%d\n",
761 dp->d_name, dp->d_unit);
764 if (dp->d_flags & DISKFLAG_RESERVED) {
765 printf("WARNING: Attempt to add non-MPSAFE disk %s%d\n",
766 dp->d_name, dp->d_unit);
767 printf("WARNING: Ignoring disk %s%d\n",
768 dp->d_name, dp->d_unit);
771 KASSERT(dp->d_strategy != NULL, ("disk_create need d_strategy"));
772 KASSERT(dp->d_name != NULL, ("disk_create need d_name"));
773 KASSERT(*dp->d_name != 0, ("disk_create need d_name"));
774 KASSERT(strlen(dp->d_name) < SPECNAMELEN - 4, ("disk name too long"));
775 if (dp->d_devstat == NULL)
776 dp->d_devstat = devstat_new_entry(dp->d_name, dp->d_unit,
777 dp->d_sectorsize, DEVSTAT_ALL_SUPPORTED,
778 DEVSTAT_TYPE_DIRECT, DEVSTAT_PRIORITY_MAX);
780 g_disk_ident_adjust(dp->d_ident, sizeof(dp->d_ident));
781 g_post_event(g_disk_create, dp, M_WAITOK, dp, NULL);
785 disk_destroy(struct disk *dp)
790 if (dp->d_devstat != NULL)
791 devstat_remove_entry(dp->d_devstat);
792 g_post_event(g_disk_destroy, dp, M_WAITOK, NULL);
796 disk_gone(struct disk *dp)
799 struct g_provider *pp;
803 pp = LIST_FIRST(&gp->provider);
805 KASSERT(LIST_NEXT(pp, provider) == NULL,
806 ("geom %p has more than one provider", gp));
807 g_wither_provider(pp, ENXIO);
813 disk_attr_changed(struct disk *dp, const char *attr, int flag)
816 struct g_provider *pp;
820 LIST_FOREACH(pp, &gp->provider, provider)
821 (void)g_attr_changed(pp, attr, flag);
825 disk_media_changed(struct disk *dp, int flag)
828 struct g_provider *pp;
832 pp = LIST_FIRST(&gp->provider);
834 KASSERT(LIST_NEXT(pp, provider) == NULL,
835 ("geom %p has more than one provider", gp));
836 g_media_changed(pp, flag);
842 disk_media_gone(struct disk *dp, int flag)
845 struct g_provider *pp;
849 pp = LIST_FIRST(&gp->provider);
851 KASSERT(LIST_NEXT(pp, provider) == NULL,
852 ("geom %p has more than one provider", gp));
853 g_media_gone(pp, flag);
859 disk_resize(struct disk *dp, int flag)
862 if (dp->d_destroyed || dp->d_geom == NULL)
865 return (g_post_event(g_disk_resize, dp, flag, NULL));
869 g_kern_disks(void *p, int flag __unused)
878 LIST_FOREACH(gp, &g_disk_class.geom, geom) {
879 sbuf_printf(sb, "%s%s", sp, gp->name);
886 sysctl_disks(SYSCTL_HANDLER_ARGS)
891 sb = sbuf_new_auto();
892 g_waitfor_event(g_kern_disks, sb, M_WAITOK, NULL);
893 error = SYSCTL_OUT(req, sbuf_data(sb), sbuf_len(sb) + 1);
898 SYSCTL_PROC(_kern, OID_AUTO, disks,
899 CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0,
900 sysctl_disks, "A", "names of available disks");