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