3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
23 */
24
25 #include <sys/note.h>
26 #include <sys/t_lock.h>
27 #include <sys/cmn_err.h>
28 #include <sys/instance.h>
29 #include <sys/conf.h>
30 #include <sys/stat.h>
31 #include <sys/ddi.h>
32 #include <sys/hwconf.h>
33 #include <sys/sunddi.h>
34 #include <sys/sunndi.h>
35 #include <sys/sunmdi.h>
36 #include <sys/ddi_impldefs.h>
37 #include <sys/ndi_impldefs.h>
38 #include <sys/kobj.h>
39 #include <sys/devcache.h>
40 #include <sys/devid_cache.h>
41 #include <sys/sysmacros.h>
42
718 /*
719 * Build a list of dev_t's for a device/devid
720 *
721 * The effect of this function is cumulative, adding dev_t's
722 * for the device to the list of all dev_t's for a given
723 * devid.
724 */
725 static void
726 e_devid_minor_to_devlist(
727 dev_info_t *dip,
728 char *minor_name,
729 int ndevts_alloced,
730 int *devtcntp,
731 dev_t *devtsp)
732 {
733 int circ;
734 struct ddi_minor_data *dmdp;
735 int minor_all = 0;
736 int ndevts = *devtcntp;
737
738 ASSERT(i_ddi_devi_attached(dip));
739
740 /* are we looking for a set of minor nodes? */
741 if ((minor_name == DEVID_MINOR_NAME_ALL) ||
742 (minor_name == DEVID_MINOR_NAME_ALL_CHR) ||
743 (minor_name == DEVID_MINOR_NAME_ALL_BLK))
744 minor_all = 1;
745
746 /* Find matching minor names */
747 ndi_devi_enter(dip, &circ);
748 for (dmdp = DEVI(dip)->devi_minor; dmdp; dmdp = dmdp->next) {
749
750 /* Skip non-minors, and non matching minor names */
751 if ((dmdp->type != DDM_MINOR) || ((minor_all == 0) &&
752 strcmp(dmdp->ddm_name, minor_name)))
753 continue;
754
755 /* filter out minor_all mismatches */
756 if (minor_all &&
757 (((minor_name == DEVID_MINOR_NAME_ALL_CHR) &&
758 (dmdp->ddm_spec_type != S_IFCHR)) ||
|
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 /*
22 * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
24 */
25
26 #include <sys/note.h>
27 #include <sys/t_lock.h>
28 #include <sys/cmn_err.h>
29 #include <sys/instance.h>
30 #include <sys/conf.h>
31 #include <sys/stat.h>
32 #include <sys/ddi.h>
33 #include <sys/hwconf.h>
34 #include <sys/sunddi.h>
35 #include <sys/sunndi.h>
36 #include <sys/sunmdi.h>
37 #include <sys/ddi_impldefs.h>
38 #include <sys/ndi_impldefs.h>
39 #include <sys/kobj.h>
40 #include <sys/devcache.h>
41 #include <sys/devid_cache.h>
42 #include <sys/sysmacros.h>
43
719 /*
720 * Build a list of dev_t's for a device/devid
721 *
722 * The effect of this function is cumulative, adding dev_t's
723 * for the device to the list of all dev_t's for a given
724 * devid.
725 */
726 static void
727 e_devid_minor_to_devlist(
728 dev_info_t *dip,
729 char *minor_name,
730 int ndevts_alloced,
731 int *devtcntp,
732 dev_t *devtsp)
733 {
734 int circ;
735 struct ddi_minor_data *dmdp;
736 int minor_all = 0;
737 int ndevts = *devtcntp;
738
739 if (!i_ddi_devi_attached(dip)) {
740 return;
741 }
742
743 /* are we looking for a set of minor nodes? */
744 if ((minor_name == DEVID_MINOR_NAME_ALL) ||
745 (minor_name == DEVID_MINOR_NAME_ALL_CHR) ||
746 (minor_name == DEVID_MINOR_NAME_ALL_BLK))
747 minor_all = 1;
748
749 /* Find matching minor names */
750 ndi_devi_enter(dip, &circ);
751 for (dmdp = DEVI(dip)->devi_minor; dmdp; dmdp = dmdp->next) {
752
753 /* Skip non-minors, and non matching minor names */
754 if ((dmdp->type != DDM_MINOR) || ((minor_all == 0) &&
755 strcmp(dmdp->ddm_name, minor_name)))
756 continue;
757
758 /* filter out minor_all mismatches */
759 if (minor_all &&
760 (((minor_name == DEVID_MINOR_NAME_ALL_CHR) &&
761 (dmdp->ddm_spec_type != S_IFCHR)) ||
|