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