Print this page
dccp: fix setsockopt bug
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/devfsadm/misc_link.c
+++ new/usr/src/cmd/devfsadm/misc_link.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 (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25
26 26 #include <regex.h>
27 27 #include <devfsadm.h>
28 28 #include <stdio.h>
29 29 #include <strings.h>
30 30 #include <stdlib.h>
31 31 #include <limits.h>
32 32 #include <sys/zone.h>
33 33 #include <sys/zcons.h>
34 34 #include <sys/cpuid_drv.h>
35 35
36 36 static int display(di_minor_t minor, di_node_t node);
37 37 static int parallel(di_minor_t minor, di_node_t node);
38 38 static int node_slash_minor(di_minor_t minor, di_node_t node);
39 39 static int driver_minor(di_minor_t minor, di_node_t node);
40 40 static int node_name(di_minor_t minor, di_node_t node);
41 41 static int minor_name(di_minor_t minor, di_node_t node);
42 42 static int wifi_minor_name(di_minor_t minor, di_node_t node);
43 43 static int conskbd(di_minor_t minor, di_node_t node);
44 44 static int consms(di_minor_t minor, di_node_t node);
45 45 static int power_button(di_minor_t minor, di_node_t node);
46 46 static int fc_port(di_minor_t minor, di_node_t node);
47 47 static int printer_create(di_minor_t minor, di_node_t node);
48 48 static int se_hdlc_create(di_minor_t minor, di_node_t node);
49 49 static int ppm(di_minor_t minor, di_node_t node);
50 50 static int gpio(di_minor_t minor, di_node_t node);
51 51 static int av_create(di_minor_t minor, di_node_t node);
52 52 static int tsalarm_create(di_minor_t minor, di_node_t node);
53 53 static int ntwdt_create(di_minor_t minor, di_node_t node);
54 54 static int zcons_create(di_minor_t minor, di_node_t node);
55 55 static int cpuid(di_minor_t minor, di_node_t node);
56 56 static int glvc(di_minor_t minor, di_node_t node);
57 57 static int ses_callback(di_minor_t minor, di_node_t node);
58 58 static int kmdrv_create(di_minor_t minor, di_node_t node);
59 59
60 60 static devfsadm_create_t misc_cbt[] = {
61 61 { "pseudo", "ddi_pseudo", "(^sad$)",
62 62 TYPE_EXACT | DRV_RE, ILEVEL_0, node_slash_minor
63 63 },
64 64 { "pseudo", "ddi_pseudo", "zsh",
65 65 TYPE_EXACT | DRV_EXACT, ILEVEL_0, driver_minor
66 66 },
67 67 { "network", "ddi_network", NULL,
68 68 TYPE_EXACT, ILEVEL_0, minor_name
69 69 },
70 70 { "wifi", "ddi_network:wifi", NULL,
71 71 TYPE_EXACT, ILEVEL_0, wifi_minor_name
72 72 },
73 73 { "display", "ddi_display", NULL,
74 74 TYPE_EXACT, ILEVEL_0, display
75 75 },
76 76 { "parallel", "ddi_parallel", NULL,
77 77 TYPE_EXACT, ILEVEL_0, parallel
78 78 },
79 79 { "enclosure", DDI_NT_SCSI_ENCLOSURE, NULL,
80 80 TYPE_EXACT, ILEVEL_0, ses_callback
81 81 },
82 82 { "pseudo", "ddi_pseudo", "(^winlock$)|(^pm$)",
83 83 TYPE_EXACT | DRV_RE, ILEVEL_0, node_name
84 84 },
85 85 { "pseudo", "ddi_pseudo", "conskbd",
86 86 TYPE_EXACT | DRV_EXACT, ILEVEL_0, conskbd
87 87 },
88 88 { "pseudo", "ddi_pseudo", "consms",
89 89 TYPE_EXACT | DRV_EXACT, ILEVEL_0, consms
90 90 },
91 91 { "pseudo", "ddi_pseudo", "rsm",
92 92 TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
93 93 },
↓ open down ↓ |
93 lines elided |
↑ open up ↑ |
94 94 { "pseudo", "ddi_pseudo",
95 95 "(^lockstat$)|(^SUNW,rtvc$)|(^vol$)|(^log$)|(^sy$)|"
96 96 "(^ksyms$)|(^clone$)|(^tl$)|(^tnf$)|(^kstat$)|(^mdesc$)|(^eeprom$)|"
97 97 "(^ptsl$)|(^mm$)|(^wc$)|(^dump$)|(^cn$)|(^svvslo$)|(^ptm$)|"
98 98 "(^ptc$)|(^openeepr$)|(^poll$)|(^sysmsg$)|(^random$)|(^trapstat$)|"
99 99 "(^cryptoadm$)|(^crypto$)|(^pool$)|(^poolctl$)|(^bl$)|(^kmdb$)|"
100 100 "(^sysevent$)|(^kssl$)|(^physmem$)",
101 101 TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name
102 102 },
103 103 { "pseudo", "ddi_pseudo",
104 - "(^ip$)|(^tcp$)|(^udp$)|(^icmp$)|"
105 - "(^ip6$)|(^tcp6$)|(^udp6$)|(^icmp6$)|"
104 + "(^ip$)|(^tcp$)|(^udp$)|(^icmp$)|(^dccp$)|"
105 + "(^ip6$)|(^tcp6$)|(^udp6$)|(^icmp6$)|(^dccp6$)|"
106 106 "(^rts$)|(^arp$)|(^ipsecah$)|(^ipsecesp$)|(^keysock$)|(^spdsock$)|"
107 107 "(^nca$)|(^rds$)|(^sdp$)|(^ipnet$)|(^dlpistub$)|(^bpf$)",
108 108 TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name
109 109 },
110 110 { "pseudo", "ddi_pseudo",
111 111 "(^ipf$)|(^ipnat$)|(^ipstate$)|(^ipauth$)|"
112 112 "(^ipsync$)|(^ipscan$)|(^iplookup$)",
113 113 TYPE_EXACT | DRV_RE, ILEVEL_0, minor_name,
114 114 },
115 115 { "pseudo", "ddi_pseudo", "dld",
116 116 TYPE_EXACT | DRV_EXACT, ILEVEL_0, node_name
117 117 },
118 118 { "pseudo", "ddi_pseudo",
119 119 "(^kdmouse$)|(^rootprop$)",
120 120 TYPE_EXACT | DRV_RE, ILEVEL_0, node_name
121 121 },
122 122 { "pseudo", "ddi_pseudo", "tod",
123 123 TYPE_EXACT | DRV_EXACT, ILEVEL_0, node_name
124 124 },
125 125 { "pseudo", "ddi_pseudo", "envctrl(two)?",
126 126 TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name,
127 127 },
128 128 { "pseudo", "ddi_pseudo", "fcode",
129 129 TYPE_EXACT | DRV_RE, ILEVEL_0, minor_name,
130 130 },
131 131 { "power_button", "ddi_power_button", NULL,
132 132 TYPE_EXACT, ILEVEL_0, power_button,
133 133 },
134 134 { "FC port", "ddi_ctl:devctl", "fp",
135 135 TYPE_EXACT | DRV_EXACT, ILEVEL_0, fc_port
136 136 },
137 137 { "printer", "ddi_printer", NULL,
138 138 TYPE_EXACT, ILEVEL_0, printer_create
139 139 },
140 140 { "pseudo", "ddi_pseudo", "se",
141 141 TYPE_EXACT | DRV_EXACT, ILEVEL_0, se_hdlc_create
142 142 },
143 143 { "ppm", "ddi_ppm", NULL,
144 144 TYPE_EXACT, ILEVEL_0, ppm
145 145 },
146 146 { "pseudo", "ddi_pseudo", "gpio_87317",
147 147 TYPE_EXACT | DRV_EXACT, ILEVEL_0, gpio
148 148 },
149 149 { "pseudo", "ddi_pseudo", "sckmdrv",
150 150 TYPE_EXACT | DRV_RE, ILEVEL_0, kmdrv_create,
151 151 },
152 152 { "pseudo", "ddi_pseudo", "oplkmdrv",
153 153 TYPE_EXACT | DRV_RE, ILEVEL_0, kmdrv_create,
154 154 },
155 155 { "av", "^ddi_av:(isoch|async)$", NULL,
156 156 TYPE_RE, ILEVEL_0, av_create,
157 157 },
158 158 { "pseudo", "ddi_pseudo", "tsalarm",
159 159 TYPE_EXACT | DRV_RE, ILEVEL_0, tsalarm_create,
160 160 },
161 161 { "pseudo", "ddi_pseudo", "ntwdt",
162 162 TYPE_EXACT | DRV_RE, ILEVEL_0, ntwdt_create,
163 163 },
164 164 { "pseudo", "ddi_pseudo", "daplt",
165 165 TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
166 166 },
167 167 { "pseudo", "ddi_pseudo", "zcons",
168 168 TYPE_EXACT | DRV_EXACT, ILEVEL_0, zcons_create,
169 169 },
170 170 { "pseudo", "ddi_pseudo", CPUID_DRIVER_NAME,
171 171 TYPE_EXACT | DRV_EXACT, ILEVEL_0, cpuid,
172 172 },
173 173 { "pseudo", "ddi_pseudo", "glvc",
174 174 TYPE_EXACT | DRV_EXACT, ILEVEL_0, glvc,
175 175 },
176 176 { "pseudo", "ddi_pseudo", "dm2s",
177 177 TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name,
178 178 },
179 179 { "pseudo", "ddi_pseudo", "nsmb",
180 180 TYPE_EXACT | DRV_EXACT, ILEVEL_1, minor_name,
181 181 },
182 182 { "pseudo", "ddi_pseudo", "mem_cache",
183 183 TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name,
184 184 },
185 185 { "pseudo", "ddi_pseudo", "fm",
186 186 TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name,
187 187 },
188 188 { "pseudo", "ddi_pseudo", "smbsrv",
189 189 TYPE_EXACT | DRV_EXACT, ILEVEL_1, minor_name,
190 190 },
191 191 { "pseudo", "ddi_pseudo", "tpm",
192 192 TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
193 193 },
194 194 };
195 195
196 196 DEVFSADM_CREATE_INIT_V0(misc_cbt);
197 197
198 198 static devfsadm_remove_t misc_remove_cbt[] = {
199 199 { "pseudo", "^profile$",
200 200 RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
201 201 },
202 202 { "pseudo", "^rsm$",
203 203 RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
204 204 },
205 205 { "printer", "^printers/[0-9]+$",
206 206 RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
207 207 },
208 208 { "av", "^av/[0-9]+/(async|isoch)$",
209 209 RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
210 210 },
211 211 { "pseudo", "^daplt$",
212 212 RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
213 213 },
214 214 { "pseudo", "^zcons/" ZONENAME_REGEXP "/(" ZCONS_MASTER_NAME "|"
215 215 ZCONS_SLAVE_NAME ")$",
216 216 RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
217 217 },
218 218 { "pseudo", "^" CPUID_SELF_NAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
219 219 ILEVEL_0, devfsadm_rm_all
220 220 },
221 221 { "enclosure", "^es/ses[0-9]+$", RM_POST,
222 222 ILEVEL_0, devfsadm_rm_all
223 223 },
224 224 { "pseudo", "^pfil$",
225 225 RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
226 226 },
227 227 { "pseudo", "^tpm$",
228 228 RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
229 229 },
230 230 { "pseudo", "^sctp|sctp6$",
231 231 RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_link
232 232 }
233 233 };
234 234
235 235 /* Rules for gpio devices */
236 236 static devfsadm_enumerate_t gpio_rules[1] =
237 237 {"^gpio([0-9]+)$", 1, MATCH_ALL};
238 238
239 239 DEVFSADM_REMOVE_INIT_V0(misc_remove_cbt);
240 240
241 241 /*
242 242 * Handles minor node type "ddi_display".
243 243 *
244 244 * type=ddi_display fbs/\M0 fb\N0
245 245 */
246 246 static int
247 247 display(di_minor_t minor, di_node_t node)
248 248 {
249 249 char l_path[PATH_MAX + 1], contents[PATH_MAX + 1], *buf;
250 250 devfsadm_enumerate_t rules[1] = {"^fb([0-9]+)$", 1, MATCH_ALL};
251 251 char *mn = di_minor_name(minor);
252 252
253 253 /* create fbs/\M0 primary link */
254 254 (void) strcpy(l_path, "fbs/");
255 255 (void) strcat(l_path, mn);
256 256 (void) devfsadm_mklink(l_path, node, minor, 0);
257 257
258 258 /* create fb\N0 which links to fbs/\M0 */
259 259 if (devfsadm_enumerate_int(l_path, 0, &buf, rules, 1)) {
260 260 return (DEVFSADM_CONTINUE);
261 261 }
262 262 (void) strcpy(contents, l_path);
263 263 (void) strcpy(l_path, "fb");
264 264 (void) strcat(l_path, buf);
265 265 free(buf);
266 266 (void) devfsadm_secondary_link(l_path, contents, 0);
267 267 return (DEVFSADM_CONTINUE);
268 268 }
269 269
270 270 /*
271 271 * Handles minor node type "ddi_parallel".
272 272 * type=ddi_parallel;name=mcpp mcpp\N0
273 273 */
274 274 static int
275 275 parallel(di_minor_t minor, di_node_t node)
276 276 {
277 277 char path[PATH_MAX + 1], *buf;
278 278 devfsadm_enumerate_t rules[1] = {"mcpp([0-9]+)$", 1, MATCH_ALL};
279 279
280 280
281 281 if (strcmp(di_node_name(node), "mcpp") != 0) {
282 282 return (DEVFSADM_CONTINUE);
283 283 }
284 284
285 285 if (NULL == (buf = di_devfs_path(node))) {
286 286 return (DEVFSADM_CONTINUE);
287 287 }
288 288
289 289 (void) snprintf(path, sizeof (path), "%s:%s",
290 290 buf, di_minor_name(minor));
291 291
292 292 di_devfs_path_free(buf);
293 293
294 294 if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
295 295 return (DEVFSADM_CONTINUE);
296 296 }
297 297 (void) snprintf(path, sizeof (path), "mcpp%s", buf);
298 298 free(buf);
299 299
300 300 (void) devfsadm_mklink(path, node, minor, 0);
301 301 return (DEVFSADM_CONTINUE);
302 302 }
303 303
304 304 static int
305 305 ses_callback(di_minor_t minor, di_node_t node)
306 306 {
307 307 char l_path[PATH_MAX];
308 308 char *buf;
309 309 char *devfspath;
310 310 char p_path[PATH_MAX];
311 311 devfsadm_enumerate_t re[] = {"^es$/^ses([0-9]+)$", 1, MATCH_ALL};
312 312
313 313 /* find devices path -- need to free mem */
314 314 if (NULL == (devfspath = di_devfs_path(node))) {
315 315 return (DEVFSADM_CONTINUE);
316 316 }
317 317
318 318 (void) snprintf(p_path, sizeof (p_path), "%s:%s", devfspath,
319 319 di_minor_name(minor));
320 320
321 321
322 322 /* find next number to use; buf is an ascii number */
323 323 if (devfsadm_enumerate_int(p_path, 0, &buf, re, 1)) {
324 324 /* free memory */
325 325 di_devfs_path_free(devfspath);
326 326 return (DEVFSADM_CONTINUE);
327 327 }
328 328
329 329 (void) snprintf(l_path, sizeof (l_path), "es/ses%s", buf);
330 330
331 331 (void) devfsadm_mklink(l_path, node, minor, 0);
332 332 /* free memory */
333 333 free(buf);
334 334 di_devfs_path_free(devfspath);
335 335 return (DEVFSADM_CONTINUE);
336 336
337 337 }
338 338
339 339 static int
340 340 node_slash_minor(di_minor_t minor, di_node_t node)
341 341 {
342 342
343 343 char path[PATH_MAX + 1];
344 344
345 345 (void) strcpy(path, di_node_name(node));
346 346 (void) strcat(path, "/");
347 347 (void) strcat(path, di_minor_name(minor));
348 348 (void) devfsadm_mklink(path, node, minor, 0);
349 349 return (DEVFSADM_CONTINUE);
350 350 }
351 351
352 352 static int
353 353 driver_minor(di_minor_t minor, di_node_t node)
354 354 {
355 355 char path[PATH_MAX + 1];
356 356
357 357 (void) strcpy(path, di_driver_name(node));
358 358 (void) strcat(path, di_minor_name(minor));
359 359 (void) devfsadm_mklink(path, node, minor, 0);
360 360 return (DEVFSADM_CONTINUE);
361 361 }
362 362
363 363 /*
364 364 * Handles links of the form:
365 365 * type=ddi_pseudo;name=xyz \D
366 366 */
367 367 static int
368 368 node_name(di_minor_t minor, di_node_t node)
369 369 {
370 370 (void) devfsadm_mklink(di_node_name(node), node, minor, 0);
371 371 return (DEVFSADM_CONTINUE);
372 372 }
373 373
374 374 /*
375 375 * Handles links of the form:
376 376 * type=ddi_pseudo;name=xyz \M0
377 377 */
378 378 static int
379 379 minor_name(di_minor_t minor, di_node_t node)
380 380 {
381 381 char *mn = di_minor_name(minor);
382 382
383 383 (void) devfsadm_mklink(mn, node, minor, 0);
384 384 if (strcmp(mn, "icmp") == 0) {
385 385 (void) devfsadm_mklink("rawip", node, minor, 0);
386 386 }
387 387 if (strcmp(mn, "icmp6") == 0) {
388 388 (void) devfsadm_mklink("rawip6", node, minor, 0);
389 389 }
390 390 if (strcmp(mn, "ipf") == 0) {
391 391 (void) devfsadm_mklink("ipl", node, minor, 0);
392 392 }
393 393 return (DEVFSADM_CONTINUE);
394 394 }
395 395
396 396 /*
397 397 * create links at /dev/wifi for wifi minor node
398 398 */
399 399 static int
400 400 wifi_minor_name(di_minor_t minor, di_node_t node)
401 401 {
402 402 char buf[256];
403 403 char *mn = di_minor_name(minor);
404 404
405 405 (void) snprintf(buf, sizeof (buf), "%s%s", "wifi/", mn);
406 406 (void) devfsadm_mklink(buf, node, minor, 0);
407 407
408 408 return (DEVFSADM_CONTINUE);
409 409 }
410 410
411 411 static int
412 412 conskbd(di_minor_t minor, di_node_t node)
413 413 {
414 414 (void) devfsadm_mklink("kbd", node, minor, 0);
415 415 return (DEVFSADM_CONTINUE);
416 416 }
417 417
418 418 static int
419 419 consms(di_minor_t minor, di_node_t node)
420 420 {
421 421 (void) devfsadm_mklink("mouse", node, minor, 0);
422 422 return (DEVFSADM_CONTINUE);
423 423 }
424 424
425 425 static int
426 426 power_button(di_minor_t minor, di_node_t node)
427 427 {
428 428 (void) devfsadm_mklink("power_button", node, minor, 0);
429 429 return (DEVFSADM_CONTINUE);
430 430 }
431 431
432 432 static int
433 433 fc_port(di_minor_t minor, di_node_t node)
434 434 {
435 435 devfsadm_enumerate_t rules[1] = {"fc/fp([0-9]+)$", 1, MATCH_ALL};
436 436 char *buf, path[PATH_MAX + 1];
437 437 char *ptr;
438 438
439 439 if (NULL == (ptr = di_devfs_path(node))) {
440 440 return (DEVFSADM_CONTINUE);
441 441 }
442 442
443 443 (void) strcpy(path, ptr);
444 444 (void) strcat(path, ":");
445 445 (void) strcat(path, di_minor_name(minor));
446 446
447 447 di_devfs_path_free(ptr);
448 448
449 449 if (devfsadm_enumerate_int(path, 0, &buf, rules, 1) != 0) {
450 450 return (DEVFSADM_CONTINUE);
451 451 }
452 452
453 453 (void) strcpy(path, "fc/fp");
454 454 (void) strcat(path, buf);
455 455 free(buf);
456 456
457 457 (void) devfsadm_mklink(path, node, minor, 0);
458 458 return (DEVFSADM_CONTINUE);
459 459 }
460 460
461 461 /*
462 462 * Handles:
463 463 * minor node type "ddi_printer".
464 464 * rules of the form: type=ddi_printer;name=bpp \M0
465 465 */
466 466 static int
467 467 printer_create(di_minor_t minor, di_node_t node)
468 468 {
469 469 char *mn;
470 470 char path[PATH_MAX + 1], *buf;
471 471 devfsadm_enumerate_t rules[1] = {"^printers$/^([0-9]+)$", 1, MATCH_ALL};
472 472
473 473 mn = di_minor_name(minor);
474 474
475 475 if (strcmp(di_driver_name(node), "bpp") == 0) {
476 476 (void) devfsadm_mklink(mn, node, minor, 0);
477 477 }
478 478
479 479 if (NULL == (buf = di_devfs_path(node))) {
480 480 return (DEVFSADM_CONTINUE);
481 481 }
482 482
483 483 (void) snprintf(path, sizeof (path), "%s:%s", buf, mn);
484 484 di_devfs_path_free(buf);
485 485
486 486 if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
487 487 return (DEVFSADM_CONTINUE);
488 488 }
489 489
490 490 (void) snprintf(path, sizeof (path), "printers/%s", buf);
491 491 free(buf);
492 492
493 493 (void) devfsadm_mklink(path, node, minor, 0);
494 494
495 495 return (DEVFSADM_CONTINUE);
496 496 }
497 497
498 498 /*
499 499 * Handles links of the form:
500 500 * type=ddi_pseudo;name=se;minor2=hdlc se_hdlc\N0
501 501 * type=ddi_pseudo;name=serial;minor2=hdlc se_hdlc\N0
502 502 */
503 503 static int
504 504 se_hdlc_create(di_minor_t minor, di_node_t node)
505 505 {
506 506 devfsadm_enumerate_t rules[1] = {"^se_hdlc([0-9]+)$", 1, MATCH_ALL};
507 507 char *buf, path[PATH_MAX + 1];
508 508 char *ptr;
509 509 char *mn;
510 510
511 511 mn = di_minor_name(minor);
512 512
513 513 /* minor node should be of the form: "?,hdlc" */
514 514 if (strcmp(mn + 1, ",hdlc") != 0) {
515 515 return (DEVFSADM_CONTINUE);
516 516 }
517 517
518 518 if (NULL == (ptr = di_devfs_path(node))) {
519 519 return (DEVFSADM_CONTINUE);
520 520 }
521 521
522 522 (void) strcpy(path, ptr);
523 523 (void) strcat(path, ":");
524 524 (void) strcat(path, mn);
525 525
526 526 di_devfs_path_free(ptr);
527 527
528 528 if (devfsadm_enumerate_int(path, 0, &buf, rules, 1) != 0) {
529 529 return (DEVFSADM_CONTINUE);
530 530 }
531 531
532 532 (void) strcpy(path, "se_hdlc");
533 533 (void) strcat(path, buf);
534 534 free(buf);
535 535
536 536 (void) devfsadm_mklink(path, node, minor, 0);
537 537
538 538 return (DEVFSADM_CONTINUE);
539 539 }
540 540
541 541 static int
542 542 gpio(di_minor_t minor, di_node_t node)
543 543 {
544 544 char l_path[PATH_MAX], p_path[PATH_MAX], *buf, *devfspath;
545 545 char *minor_nm, *drvr_nm;
546 546
547 547
548 548 minor_nm = di_minor_name(minor);
549 549 drvr_nm = di_driver_name(node);
550 550 if ((minor_nm == NULL) || (drvr_nm == NULL)) {
551 551 return (DEVFSADM_CONTINUE);
552 552 }
553 553
554 554 devfspath = di_devfs_path(node);
555 555
556 556 (void) strcpy(p_path, devfspath);
557 557 (void) strcat(p_path, ":");
558 558 (void) strcat(p_path, minor_nm);
559 559 di_devfs_path_free(devfspath);
560 560
561 561 /* build the physical path from the components */
562 562 if (devfsadm_enumerate_int(p_path, 0, &buf, gpio_rules, 1)) {
563 563 return (DEVFSADM_CONTINUE);
564 564 }
565 565
566 566 (void) snprintf(l_path, sizeof (l_path), "%s%s", "gpio", buf);
567 567
568 568 free(buf);
569 569
570 570 (void) devfsadm_mklink(l_path, node, minor, 0);
571 571
572 572 return (DEVFSADM_CONTINUE);
573 573 }
574 574
575 575 /*
576 576 * Creates /dev/ppm nodes for Platform Specific PM module
577 577 */
578 578 static int
579 579 ppm(di_minor_t minor, di_node_t node)
580 580 {
581 581 (void) devfsadm_mklink("ppm", node, minor, 0);
582 582 return (DEVFSADM_CONTINUE);
583 583 }
584 584
585 585 /*
586 586 * Handles:
587 587 * /dev/av/[0-9]+/(async|isoch)
588 588 */
589 589 static int
590 590 av_create(di_minor_t minor, di_node_t node)
591 591 {
592 592 devfsadm_enumerate_t rules[1] = {"^av$/^([0-9]+)$", 1, MATCH_ADDR};
593 593 char *minor_str;
594 594 char path[PATH_MAX + 1];
595 595 char *buf;
596 596
597 597 if ((buf = di_devfs_path(node)) == NULL) {
598 598 return (DEVFSADM_CONTINUE);
599 599 }
600 600
601 601 minor_str = di_minor_name(minor);
602 602 (void) snprintf(path, sizeof (path), "%s:%s", buf, minor_str);
603 603 di_devfs_path_free(buf);
604 604
605 605 if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
606 606 return (DEVFSADM_CONTINUE);
607 607 }
608 608
609 609 (void) snprintf(path, sizeof (path), "av/%s/%s", buf, minor_str);
610 610 free(buf);
611 611
612 612 (void) devfsadm_mklink(path, node, minor, 0);
613 613
614 614 return (DEVFSADM_CONTINUE);
615 615 }
616 616
617 617 /*
618 618 * Creates /dev/lom and /dev/tsalarm:ctl for tsalarm node
619 619 */
620 620 static int
621 621 tsalarm_create(di_minor_t minor, di_node_t node)
622 622 {
623 623 char buf[PATH_MAX + 1];
624 624 char *mn = di_minor_name(minor);
625 625
626 626 (void) snprintf(buf, sizeof (buf), "%s%s", di_node_name(node), ":ctl");
627 627
628 628 (void) devfsadm_mklink(mn, node, minor, 0);
629 629 (void) devfsadm_mklink(buf, node, minor, 0);
630 630
631 631 return (DEVFSADM_CONTINUE);
632 632 }
633 633
634 634 /*
635 635 * Creates /dev/ntwdt for ntwdt node
636 636 */
637 637 static int
638 638 ntwdt_create(di_minor_t minor, di_node_t node)
639 639 {
640 640 (void) devfsadm_mklink("ntwdt", node, minor, 0);
641 641 return (DEVFSADM_CONTINUE);
642 642 }
643 643
644 644 static int
645 645 zcons_create(di_minor_t minor, di_node_t node)
646 646 {
647 647 char *minor_str;
648 648 char *zonename;
649 649 char path[MAXPATHLEN];
650 650
651 651 minor_str = di_minor_name(minor);
652 652
653 653 if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, "zonename",
654 654 &zonename) == -1) {
655 655 return (DEVFSADM_CONTINUE);
656 656 }
657 657
658 658 (void) snprintf(path, sizeof (path), "zcons/%s/%s", zonename,
659 659 minor_str);
660 660 (void) devfsadm_mklink(path, node, minor, 0);
661 661
662 662 return (DEVFSADM_CONTINUE);
663 663 }
664 664
665 665 /*
666 666 * /dev/cpu/self/cpuid -> /devices/pseudo/cpuid@0:self
667 667 */
668 668 static int
669 669 cpuid(di_minor_t minor, di_node_t node)
670 670 {
671 671 (void) devfsadm_mklink(CPUID_SELF_NAME, node, minor, 0);
672 672 return (DEVFSADM_CONTINUE);
673 673 }
674 674
675 675 /*
676 676 * For device
677 677 * /dev/spfma -> /devices/virtual-devices/fma@5:glvc
678 678 */
679 679 static int
680 680 glvc(di_minor_t minor, di_node_t node)
681 681 {
682 682 char node_name[MAXNAMELEN + 1];
683 683
684 684 (void) strcpy(node_name, di_node_name(node));
685 685
686 686 if (strncmp(node_name, "fma", 3) == 0) {
687 687 /* Only one fma channel */
688 688 (void) devfsadm_mklink("spfma", node, minor, 0);
689 689 }
690 690 return (DEVFSADM_CONTINUE);
691 691 }
692 692
693 693 /*
694 694 * Handles links of the form:
695 695 * type=ddi_pseudo;name=sckmdrv kmdrv\M0
696 696 * type=ddi_pseudo;name=oplkmdrv kmdrv\M0
697 697 */
698 698 static int
699 699 kmdrv_create(di_minor_t minor, di_node_t node)
700 700 {
701 701
702 702 (void) devfsadm_mklink("kmdrv", node, minor, 0);
703 703 return (DEVFSADM_CONTINUE);
704 704 }
↓ open down ↓ |
589 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX