Wed Apr 27 02:19:12 2016 UTC ()
Add dkwedge_find_by_parent()


(christos)
diff -r1.88 -r1.89 src/sys/dev/dkwedge/dk.c
diff -r1.66 -r1.67 src/sys/sys/disk.h

cvs diff -r1.88 -r1.89 src/sys/dev/dkwedge/dk.c (expand / switch to unified diff)

--- src/sys/dev/dkwedge/dk.c 2016/01/15 07:48:22 1.88
+++ src/sys/dev/dkwedge/dk.c 2016/04/27 02:19:12 1.89
@@ -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
 764device_t
 765dkwedge_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
764void 781void
765dkwedge_print_wnames(void) 782dkwedge_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);

cvs diff -r1.66 -r1.67 src/sys/sys/disk.h (expand / switch to unified diff)

--- src/sys/sys/disk.h 2015/11/12 15:25:22 1.66
+++ src/sys/sys/disk.h 2016/04/27 02:19:12 1.67
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: disk.h,v 1.66 2015/11/12 15:25:22 christos Exp $ */ 1/* $NetBSD: disk.h,v 1.67 2016/04/27 02:19:12 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc. 4 * Copyright (c) 1996, 1997, 2004 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 of the Numerical Aerospace Simulation Facility, 8 * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
9 * NASA Ames Research Center. 9 * NASA Ames Research Center.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or without 11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions 12 * modification, are permitted provided that the following conditions
13 * are met: 13 * are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -537,19 +537,21 @@ void disk_unbusy(struct disk *, long, in @@ -537,19 +537,21 @@ void disk_unbusy(struct disk *, long, in
537bool disk_isbusy(struct disk *); 537bool disk_isbusy(struct disk *);
538struct disk *disk_find(const char *); 538struct disk *disk_find(const char *);
539int disk_ioctl(struct disk *, dev_t, u_long, void *, int, struct lwp *); 539int disk_ioctl(struct disk *, dev_t, u_long, void *, int, struct lwp *);
540void disk_set_info(device_t, struct disk *, const char *); 540void disk_set_info(device_t, struct disk *, const char *);
541 541
542void dkwedge_init(void); 542void dkwedge_init(void);
543int dkwedge_add(struct dkwedge_info *); 543int dkwedge_add(struct dkwedge_info *);
544int dkwedge_del(struct dkwedge_info *); 544int dkwedge_del(struct dkwedge_info *);
545void dkwedge_delall(struct disk *); 545void dkwedge_delall(struct disk *);
546int dkwedge_list(struct disk *, struct dkwedge_list *, struct lwp *); 546int dkwedge_list(struct disk *, struct dkwedge_list *, struct lwp *);
547void dkwedge_discover(struct disk *); 547void dkwedge_discover(struct disk *);
548int dkwedge_read(struct disk *, struct vnode *, daddr_t, void *, size_t); 548int dkwedge_read(struct disk *, struct vnode *, daddr_t, void *, size_t);
549device_t dkwedge_find_by_wname(const char *); 549device_t dkwedge_find_by_wname(const char *);
 550device_t dkwedge_find_by_parent(const char *, size_t *);
550const char *dkwedge_get_parent_name(dev_t); 551const char *dkwedge_get_parent_name(dev_t);
551void dkwedge_print_wnames(void); 552void dkwedge_print_wnames(void);
552device_t dkwedge_find_partition(device_t, daddr_t, uint64_t); 553device_t dkwedge_find_partition(device_t, daddr_t, uint64_t);
 554
553#endif 555#endif
554 556
555#endif /* _SYS_DISK_H_ */ 557#endif /* _SYS_DISK_H_ */