| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: dk.c,v 1.88 2016/01/15 07:48:22 mlelstv Exp $ */ | | 1 | /* $NetBSD: dk.c,v 1.89 2016/04/27 02:19:12 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2004, 2005, 2006, 2007 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe. | | 8 | * by Jason R. Thorpe. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -20,27 +20,27 @@ | | | @@ -20,27 +20,27 @@ |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | #include <sys/cdefs.h> | | 32 | #include <sys/cdefs.h> |
33 | __KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.88 2016/01/15 07:48:22 mlelstv Exp $"); | | 33 | __KERNEL_RCSID(0, "$NetBSD: dk.c,v 1.89 2016/04/27 02:19:12 christos Exp $"); |
34 | | | 34 | |
35 | #ifdef _KERNEL_OPT | | 35 | #ifdef _KERNEL_OPT |
36 | #include "opt_dkwedge.h" | | 36 | #include "opt_dkwedge.h" |
37 | #endif | | 37 | #endif |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/proc.h> | | 41 | #include <sys/proc.h> |
42 | #include <sys/errno.h> | | 42 | #include <sys/errno.h> |
43 | #include <sys/pool.h> | | 43 | #include <sys/pool.h> |
44 | #include <sys/ioctl.h> | | 44 | #include <sys/ioctl.h> |
45 | #include <sys/disklabel.h> | | 45 | #include <sys/disklabel.h> |
46 | #include <sys/disk.h> | | 46 | #include <sys/disk.h> |
| @@ -751,26 +751,43 @@ dkwedge_find_by_wname(const char *wname) | | | @@ -751,26 +751,43 @@ dkwedge_find_by_wname(const char *wname) |
751 | printf( | | 751 | printf( |
752 | "WARNING: double match for wedge name %s " | | 752 | "WARNING: double match for wedge name %s " |
753 | "(%s, %s)\n", wname, device_xname(dv), | | 753 | "(%s, %s)\n", wname, device_xname(dv), |
754 | device_xname(sc->sc_dev)); | | 754 | device_xname(sc->sc_dev)); |
755 | continue; | | 755 | continue; |
756 | } | | 756 | } |
757 | dv = sc->sc_dev; | | 757 | dv = sc->sc_dev; |
758 | } | | 758 | } |
759 | } | | 759 | } |
760 | rw_exit(&dkwedges_lock); | | 760 | rw_exit(&dkwedges_lock); |
761 | return dv; | | 761 | return dv; |
762 | } | | 762 | } |
763 | | | 763 | |
| | | 764 | device_t |
| | | 765 | dkwedge_find_by_parent(const char *name, size_t *i) |
| | | 766 | { |
| | | 767 | rw_enter(&dkwedges_lock, RW_WRITER); |
| | | 768 | for (; *i < (size_t)ndkwedges; (*i)++) { |
| | | 769 | struct dkwedge_softc *sc; |
| | | 770 | if ((sc = dkwedges[*i]) == NULL) |
| | | 771 | continue; |
| | | 772 | if (strcmp(sc->sc_parent->dk_name, name) != 0) |
| | | 773 | continue; |
| | | 774 | rw_exit(&dkwedges_lock); |
| | | 775 | return sc->sc_dev; |
| | | 776 | } |
| | | 777 | rw_exit(&dkwedges_lock); |
| | | 778 | return NULL; |
| | | 779 | } |
| | | 780 | |
764 | void | | 781 | void |
765 | dkwedge_print_wnames(void) | | 782 | dkwedge_print_wnames(void) |
766 | { | | 783 | { |
767 | struct dkwedge_softc *sc; | | 784 | struct dkwedge_softc *sc; |
768 | int i; | | 785 | int i; |
769 | | | 786 | |
770 | rw_enter(&dkwedges_lock, RW_WRITER); | | 787 | rw_enter(&dkwedges_lock, RW_WRITER); |
771 | for (i = 0; i < ndkwedges; i++) { | | 788 | for (i = 0; i < ndkwedges; i++) { |
772 | if ((sc = dkwedges[i]) == NULL) | | 789 | if ((sc = dkwedges[i]) == NULL) |
773 | continue; | | 790 | continue; |
774 | printf(" wedge:%s", sc->sc_wname); | | 791 | printf(" wedge:%s", sc->sc_wname); |
775 | } | | 792 | } |
776 | rw_exit(&dkwedges_lock); | | 793 | rw_exit(&dkwedges_lock); |