Print this page
7127 remove -Wno-missing-braces from Makefile.uts
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/io/bl.c
+++ new/usr/src/uts/common/io/bl.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26
27 27 /*
28 28 * Blacklist special file
29 29 */
30 30
31 31 #include <sys/types.h>
32 32 #include <sys/conf.h>
33 33 #include <sys/stat.h>
34 34 #include <sys/modctl.h>
35 35 #include <sys/kmem.h>
36 36 #include <sys/ddi.h>
37 37 #include <sys/sunddi.h>
38 38 #include <sys/open.h>
39 39 #include <sys/policy.h>
40 40 #include <sys/fm/protocol.h>
41 41 #include <sys/bl.h>
42 42
43 43 static dev_info_t *bl_dip; /* private copy of devinfo pointer */
44 44
45 45 static int
46 46 bl_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
47 47 {
48 48 switch (cmd) {
49 49 case DDI_ATTACH:
50 50 break;
51 51 case DDI_RESUME:
52 52 return (DDI_SUCCESS);
53 53 default:
54 54 return (DDI_FAILURE);
55 55 }
56 56
57 57 if (ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR,
58 58 ddi_get_instance(dip), DDI_PSEUDO, 0) != DDI_SUCCESS)
59 59 return (DDI_FAILURE);
60 60
61 61 bl_dip = dip;
62 62 return (DDI_SUCCESS);
63 63 }
64 64
65 65 /*ARGSUSED*/
66 66 static int
67 67 bl_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
68 68 {
69 69 switch (cmd) {
70 70 case DDI_DETACH:
71 71 break;
72 72 case DDI_SUSPEND:
73 73 return (DDI_SUCCESS);
74 74 default:
75 75 return (DDI_FAILURE);
76 76 }
77 77
78 78 ddi_remove_minor_node(bl_dip, NULL);
79 79 return (DDI_SUCCESS);
80 80 }
81 81
82 82 /*ARGSUSED*/
83 83 static int
84 84 bl_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
85 85 {
86 86 int rc = DDI_SUCCESS;
87 87
88 88 switch (infocmd) {
89 89 case DDI_INFO_DEVT2DEVINFO:
90 90 *result = bl_dip;
91 91 break;
92 92
93 93 case DDI_INFO_DEVT2INSTANCE:
94 94 *result = (void *)(uintptr_t)getminor((dev_t)arg);
95 95 break;
96 96
97 97 default:
98 98 *result = NULL;
99 99 rc = DDI_FAILURE;
100 100 }
101 101
102 102 return (rc);
103 103 }
104 104
105 105 /*ARGSUSED*/
106 106 static int
107 107 bl_open(dev_t *devp, int flag, int otyp, struct cred *credp)
108 108 {
109 109 if (otyp != OTYP_CHR)
110 110 return (EINVAL);
111 111
112 112 if (secpolicy_blacklist(credp) != 0)
113 113 return (EPERM);
114 114
115 115 return (0);
116 116 }
117 117
118 118 /*ARGSUSED*/
119 119 static int
120 120 bl_ioctl(dev_t dev, int cmd, intptr_t data, int flag, cred_t *cred, int *rvalp)
121 121 {
122 122 bl_req_t blr;
123 123 nvlist_t *fmri;
124 124 const char *scheme;
125 125 char class[128];
126 126 char *buf;
127 127 int err;
128 128
129 129 #ifdef _SYSCALL32
130 130 if (get_udatamodel() != DATAMODEL_NATIVE) {
131 131 bl_req32_t blr32;
132 132
133 133 if (copyin((void *)data, &blr32, sizeof (bl_req32_t)) != 0)
134 134 return (EFAULT);
135 135
136 136 blr.bl_fmri = (caddr_t)(uintptr_t)blr32.bl_fmri;
137 137 blr.bl_fmrisz = blr32.bl_fmrisz;
138 138
139 139 blr.bl_class = (caddr_t)(uintptr_t)blr32.bl_class;
140 140 } else
141 141 #endif
142 142 {
143 143 if (copyin((void *)data, &blr, sizeof (bl_req_t)) != 0)
144 144 return (EFAULT);
145 145 }
146 146
147 147 if (blr.bl_fmri == NULL || blr.bl_fmrisz > BL_FMRI_MAX_BUFSIZE ||
148 148 blr.bl_class == NULL)
149 149 return (EINVAL);
150 150
151 151 if (copyinstr(blr.bl_class, class, sizeof (class), NULL) != 0)
152 152 return (EFAULT);
153 153
154 154 buf = kmem_zalloc(blr.bl_fmrisz, KM_SLEEP);
155 155 if (copyin(blr.bl_fmri, buf, blr.bl_fmrisz) != 0) {
156 156 kmem_free(buf, blr.bl_fmrisz);
157 157 return (EFAULT);
158 158 }
159 159
160 160 err = nvlist_unpack(buf, blr.bl_fmrisz, &fmri, KM_SLEEP);
161 161 kmem_free(buf, blr.bl_fmrisz);
162 162 if (err != 0)
163 163 return (err);
164 164
165 165 if (nvlist_lookup_string(fmri, FM_FMRI_SCHEME, (char **)&scheme) != 0) {
166 166 nvlist_free(fmri);
167 167 return (EINVAL);
168 168 }
169 169
170 170 switch (cmd) {
171 171 case BLIOC_INSERT:
172 172 case BLIOC_DELETE:
173 173 err = blacklist(cmd, scheme, fmri, class);
174 174 break;
175 175 default:
176 176 err = ENOTSUP;
177 177 }
178 178
179 179 nvlist_free(fmri);
180 180 return (err);
181 181
182 182 }
183 183
184 184 static struct cb_ops bl_cb_ops = {
185 185 bl_open, /* open */
186 186 nulldev, /* close */
187 187 nodev, /* strategy */
188 188 nodev, /* print */
189 189 nodev, /* dump */
190 190 nodev, /* read */
191 191 nodev, /* write */
192 192 bl_ioctl, /* ioctl */
193 193 nodev, /* devmap */
194 194 nodev, /* mmap */
195 195 nodev, /* segmap */
196 196 nochpoll, /* poll */
197 197 ddi_prop_op, /* cb_prop_op */
198 198 0, /* streamtab */
199 199 D_NEW | D_MP | D_64BIT /* Driver compatibility flag */
200 200 };
201 201
202 202 static struct dev_ops bl_ops = {
203 203 DEVO_REV, /* devo_rev */
204 204 0, /* devo_refcnt */
205 205 bl_getinfo, /* devo_getinfo */
206 206 nulldev, /* devo_identify */
207 207 nulldev, /* devo_probe */
208 208 bl_attach, /* devo_attach */
209 209 bl_detach, /* devo_detach */
210 210 nodev, /* devo_reset */
211 211 &bl_cb_ops, /* devo_cb_ops */
↓ open down ↓ |
211 lines elided |
↑ open up ↑ |
212 212 (struct bus_ops *)0, /* devo_bus_ops */
213 213 NULL, /* devo_power */
214 214 ddi_quiesce_not_needed, /* devo_quiesce */
215 215 };
216 216
217 217 static struct modldrv modldrv = {
218 218 &mod_driverops, "blacklist driver", &bl_ops,
219 219 };
220 220
221 221 static struct modlinkage modlinkage = {
222 - MODREV_1, &modldrv, NULL
222 + MODREV_1, { &modldrv, NULL }
223 223 };
224 224
225 225 int
226 226 _init(void)
227 227 {
228 228 return (mod_install(&modlinkage));
229 229 }
230 230
231 231 int
232 232 _info(struct modinfo *modinfop)
233 233 {
234 234 return (mod_info(&modlinkage, modinfop));
235 235 }
236 236
237 237 int
238 238 _fini(void)
239 239 {
240 240 return (mod_remove(&modlinkage));
241 241 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX