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