xref: /illumos-gate/usr/src/cmd/devfsadm/misc_link.c (revision 2570281c)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
525cf1a30Sjl  * Common Development and Distribution License (the "License").
625cf1a30Sjl  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
225d41001aSGirish Moodalbail  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
231e4c938bSGordon Ross  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
246a72db4aSBryan Cantrill  * Copyright (c) 2015, Joyent, Inc. All rights reserved.
257d10cd4dSGarrett D'Amore  * Copyright 2022 Garrett D'Amore <garrett@damore.org>
2664439ec0SJoshua M. Clulow  * Copyright 2022 Oxide Computer Company
277c478bd9Sstevel@tonic-gate  */
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #include <regex.h>
307c478bd9Sstevel@tonic-gate #include <devfsadm.h>
317c478bd9Sstevel@tonic-gate #include <stdio.h>
327c478bd9Sstevel@tonic-gate #include <strings.h>
337c478bd9Sstevel@tonic-gate #include <stdlib.h>
347c478bd9Sstevel@tonic-gate #include <limits.h>
357c478bd9Sstevel@tonic-gate #include <sys/zone.h>
367c478bd9Sstevel@tonic-gate #include <sys/zcons.h>
377c478bd9Sstevel@tonic-gate #include <sys/cpuid_drv.h>
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate static int display(di_minor_t minor, di_node_t node);
407c478bd9Sstevel@tonic-gate static int parallel(di_minor_t minor, di_node_t node);
417c478bd9Sstevel@tonic-gate static int node_slash_minor(di_minor_t minor, di_node_t node);
427c478bd9Sstevel@tonic-gate static int driver_minor(di_minor_t minor, di_node_t node);
437c478bd9Sstevel@tonic-gate static int node_name(di_minor_t minor, di_node_t node);
447c478bd9Sstevel@tonic-gate static int minor_name(di_minor_t minor, di_node_t node);
45516fc7f3Shx static int wifi_minor_name(di_minor_t minor, di_node_t node);
467c478bd9Sstevel@tonic-gate static int conskbd(di_minor_t minor, di_node_t node);
477c478bd9Sstevel@tonic-gate static int consms(di_minor_t minor, di_node_t node);
487c478bd9Sstevel@tonic-gate static int power_button(di_minor_t minor, di_node_t node);
497c478bd9Sstevel@tonic-gate static int fc_port(di_minor_t minor, di_node_t node);
507c478bd9Sstevel@tonic-gate static int printer_create(di_minor_t minor, di_node_t node);
517c478bd9Sstevel@tonic-gate static int se_hdlc_create(di_minor_t minor, di_node_t node);
527c478bd9Sstevel@tonic-gate static int ppm(di_minor_t minor, di_node_t node);
537c478bd9Sstevel@tonic-gate static int gpio(di_minor_t minor, di_node_t node);
547c478bd9Sstevel@tonic-gate static int av_create(di_minor_t minor, di_node_t node);
557c478bd9Sstevel@tonic-gate static int tsalarm_create(di_minor_t minor, di_node_t node);
56e3f8e17dSsc static int ntwdt_create(di_minor_t minor, di_node_t node);
577c478bd9Sstevel@tonic-gate static int zcons_create(di_minor_t minor, di_node_t node);
587c478bd9Sstevel@tonic-gate static int cpuid(di_minor_t minor, di_node_t node);
597c478bd9Sstevel@tonic-gate static int glvc(di_minor_t minor, di_node_t node);
607c478bd9Sstevel@tonic-gate static int ses_callback(di_minor_t minor, di_node_t node);
6125cf1a30Sjl static int kmdrv_create(di_minor_t minor, di_node_t node);
6264439ec0SJoshua M. Clulow static int vio9p_create(di_minor_t minor, di_node_t node);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate static devfsadm_create_t misc_cbt[] = {
65facf4a8dSllai 	{ "pseudo", "ddi_pseudo", "(^sad$)",
667c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_0, node_slash_minor
677c478bd9Sstevel@tonic-gate 	},
687c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "zsh",
697c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, driver_minor
707c478bd9Sstevel@tonic-gate 	},
717c478bd9Sstevel@tonic-gate 	{ "network", "ddi_network", NULL,
727c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, minor_name
737c478bd9Sstevel@tonic-gate 	},
74516fc7f3Shx 	{ "wifi", "ddi_network:wifi", NULL,
75516fc7f3Shx 	    TYPE_EXACT, ILEVEL_0, wifi_minor_name
76516fc7f3Shx 	},
777c478bd9Sstevel@tonic-gate 	{ "display", "ddi_display", NULL,
787c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, display
797c478bd9Sstevel@tonic-gate 	},
807c478bd9Sstevel@tonic-gate 	{ "parallel", "ddi_parallel", NULL,
817c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, parallel
827c478bd9Sstevel@tonic-gate 	},
837c478bd9Sstevel@tonic-gate 	{ "enclosure", DDI_NT_SCSI_ENCLOSURE, NULL,
847c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, ses_callback
857c478bd9Sstevel@tonic-gate 	},
867c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "(^winlock$)|(^pm$)",
877c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_0, node_name
887c478bd9Sstevel@tonic-gate 	},
897c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "conskbd",
907c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, conskbd
917c478bd9Sstevel@tonic-gate 	},
927c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "consms",
937c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, consms
947c478bd9Sstevel@tonic-gate 	},
951767006bSBryan Cantrill 	{ "pseudo", "ddi_pseudo", "eventfd",
961767006bSBryan Cantrill 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
971767006bSBryan Cantrill 	},
983d729aecSJerry Jelinek 	{ "pseudo", "ddi_pseudo", "signalfd",
993d729aecSJerry Jelinek 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
1003d729aecSJerry Jelinek 	},
1017c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "rsm",
1027c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
1037c478bd9Sstevel@tonic-gate 	},
1047c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo",
1057c478bd9Sstevel@tonic-gate 	    "(^lockstat$)|(^SUNW,rtvc$)|(^vol$)|(^log$)|(^sy$)|"
106*2570281cSToomas Soome 	    "(^ksyms$)|(^clone$)|(^tl$)|(^kstat$)|(^mdesc$)|(^eeprom$)|"
107b127ac41SPhilip Kirk 	    "(^ptsl$)|(^mm$)|(^wc$)|(^dump$)|(^cn$)|(^svvslo$)|(^ptm$)|"
1087c478bd9Sstevel@tonic-gate 	    "(^ptc$)|(^openeepr$)|(^poll$)|(^sysmsg$)|(^random$)|(^trapstat$)|"
1097c478bd9Sstevel@tonic-gate 	    "(^cryptoadm$)|(^crypto$)|(^pool$)|(^poolctl$)|(^bl$)|(^kmdb$)|"
1107d10cd4dSGarrett D'Amore 	    "(^sysevent$)|(^physmem$)",
1117c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name
1127c478bd9Sstevel@tonic-gate 	},
1137c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo",
1145d41001aSGirish Moodalbail 	    "(^ip$)|(^tcp$)|(^udp$)|(^icmp$)|"
1155d41001aSGirish Moodalbail 	    "(^ip6$)|(^tcp6$)|(^udp6$)|(^icmp6$)|"
1167c478bd9Sstevel@tonic-gate 	    "(^rts$)|(^arp$)|(^ipsecah$)|(^ipsecesp$)|(^keysock$)|(^spdsock$)|"
11715f90b02SGarrett D'Amore 	    "(^rds$)|(^sdp$)|(^ipnet$)|(^dlpistub$)|(^bpf$)",
1187c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name
1197c478bd9Sstevel@tonic-gate 	},
120fe77cc04SRobert Mustacchi 	{ "pseudo", "ddi_pseudo", "ipd",
121fe77cc04SRobert Mustacchi 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
122fe77cc04SRobert Mustacchi 	},
1237c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo",
124381a2a9aSdr 	    "(^ipf$)|(^ipnat$)|(^ipstate$)|(^ipauth$)|"
1257c478bd9Sstevel@tonic-gate 	    "(^ipsync$)|(^ipscan$)|(^iplookup$)",
1267c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_0, minor_name,
1277c478bd9Sstevel@tonic-gate 	},
128eae72b5bSSebastien Roy 	{ "pseudo", "ddi_pseudo", "dld",
129eae72b5bSSebastien Roy 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, node_name
130eae72b5bSSebastien Roy 	},
1317c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo",
13257f4a14aSGarrett D'Amore 	    "(^kdmouse$)|(^rootprop$)",
1337c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_0, node_name
1347c478bd9Sstevel@tonic-gate 	},
1356a72db4aSBryan Cantrill 	{ "pseudo", "ddi_pseudo", "timerfd",
1366a72db4aSBryan Cantrill 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
1376a72db4aSBryan Cantrill 	},
1387c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "tod",
1397c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, node_name
1407c478bd9Sstevel@tonic-gate 	},
1417c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "envctrl(two)?",
1427c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name,
1437c478bd9Sstevel@tonic-gate 	},
1447c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "fcode",
1457c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_0, minor_name,
1467c478bd9Sstevel@tonic-gate 	},
1477c478bd9Sstevel@tonic-gate 	{ "power_button", "ddi_power_button", NULL,
1487c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, power_button,
1497c478bd9Sstevel@tonic-gate 	},
1507c478bd9Sstevel@tonic-gate 	{ "FC port", "ddi_ctl:devctl", "fp",
1517c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, fc_port
1527c478bd9Sstevel@tonic-gate 	},
1537c478bd9Sstevel@tonic-gate 	{ "printer", "ddi_printer", NULL,
1547c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, printer_create
1557c478bd9Sstevel@tonic-gate 	},
1567c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "se",
1577c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, se_hdlc_create
1587c478bd9Sstevel@tonic-gate 	},
1597c478bd9Sstevel@tonic-gate 	{ "ppm",  "ddi_ppm", NULL,
1607c478bd9Sstevel@tonic-gate 	    TYPE_EXACT, ILEVEL_0, ppm
1617c478bd9Sstevel@tonic-gate 	},
1627c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "gpio_87317",
1637c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, gpio
1647c478bd9Sstevel@tonic-gate 	},
1657c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "sckmdrv",
16625cf1a30Sjl 	    TYPE_EXACT | DRV_RE, ILEVEL_0, kmdrv_create,
16725cf1a30Sjl 	},
16825cf1a30Sjl 	{ "pseudo", "ddi_pseudo", "oplkmdrv",
16925cf1a30Sjl 	    TYPE_EXACT | DRV_RE, ILEVEL_0, kmdrv_create,
1707c478bd9Sstevel@tonic-gate 	},
1717c478bd9Sstevel@tonic-gate 	{ "av", "^ddi_av:(isoch|async)$", NULL,
1727c478bd9Sstevel@tonic-gate 	    TYPE_RE, ILEVEL_0, av_create,
1737c478bd9Sstevel@tonic-gate 	},
1747c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "tsalarm",
1757c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_RE, ILEVEL_0, tsalarm_create,
1767c478bd9Sstevel@tonic-gate 	},
177e3f8e17dSsc 	{ "pseudo", "ddi_pseudo", "ntwdt",
178e3f8e17dSsc 	    TYPE_EXACT | DRV_RE, ILEVEL_0, ntwdt_create,
179e3f8e17dSsc 	},
1807c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "daplt",
1817c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
1827c478bd9Sstevel@tonic-gate 	},
1837c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "zcons",
1847c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, zcons_create,
1857c478bd9Sstevel@tonic-gate 	},
1867c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", CPUID_DRIVER_NAME,
1877c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, cpuid,
1887c478bd9Sstevel@tonic-gate 	},
1897c478bd9Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "glvc",
1907c478bd9Sstevel@tonic-gate 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, glvc,
1917c478bd9Sstevel@tonic-gate 	},
19225cf1a30Sjl 	{ "pseudo", "ddi_pseudo", "dm2s",
19325cf1a30Sjl 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name,
19425cf1a30Sjl 	},
1954bff34e3Sthurlow 	{ "pseudo", "ddi_pseudo", "nsmb",
1961e4c938bSGordon Ross 	    TYPE_EXACT | DRV_EXACT, ILEVEL_1, minor_name,
1974bff34e3Sthurlow 	},
1987bebe46cSjc 	{ "pseudo", "ddi_pseudo", "mem_cache",
1997bebe46cSjc 	    TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name,
2007bebe46cSjc 	},
201e4b86885SCheng Sean Ye 	{ "pseudo", "ddi_pseudo", "fm",
202e4b86885SCheng Sean Ye 	    TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name,
2038d26100cSWyllys Ingersoll 	},
2041e4c938bSGordon Ross 	{ "pseudo", "ddi_pseudo", "smbsrv",
2051e4c938bSGordon Ross 	    TYPE_EXACT | DRV_EXACT, ILEVEL_1, minor_name,
2061e4c938bSGordon Ross 	},
2078d26100cSWyllys Ingersoll 	{ "pseudo", "ddi_pseudo", "tpm",
2088d26100cSWyllys Ingersoll 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
2098d26100cSWyllys Ingersoll 	},
21036589d6bSRobert Mustacchi 	{ "pseudo", "ddi_pseudo", "overlay",
21136589d6bSRobert Mustacchi 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, minor_name
21264439ec0SJoshua M. Clulow 	},
21364439ec0SJoshua M. Clulow 	{ "9p", "ddi_pseudo", "vio9p",
21464439ec0SJoshua M. Clulow 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, vio9p_create,
21564439ec0SJoshua M. Clulow 	},
2167c478bd9Sstevel@tonic-gate };
2177c478bd9Sstevel@tonic-gate 
2187c478bd9Sstevel@tonic-gate DEVFSADM_CREATE_INIT_V0(misc_cbt);
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate static devfsadm_remove_t misc_remove_cbt[] = {
2217c478bd9Sstevel@tonic-gate 	{ "pseudo", "^profile$",
2227c478bd9Sstevel@tonic-gate 	    RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2237c478bd9Sstevel@tonic-gate 	},
2247c478bd9Sstevel@tonic-gate 	{ "pseudo", "^rsm$",
2257c478bd9Sstevel@tonic-gate 	    RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2267c478bd9Sstevel@tonic-gate 	},
2277c478bd9Sstevel@tonic-gate 	{ "printer", "^printers/[0-9]+$",
2287c478bd9Sstevel@tonic-gate 	    RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2297c478bd9Sstevel@tonic-gate 	},
2307c478bd9Sstevel@tonic-gate 	{ "av", "^av/[0-9]+/(async|isoch)$",
2317c478bd9Sstevel@tonic-gate 	    RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2327c478bd9Sstevel@tonic-gate 	},
2337c478bd9Sstevel@tonic-gate 	{ "pseudo", "^daplt$",
2347c478bd9Sstevel@tonic-gate 	    RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2357c478bd9Sstevel@tonic-gate 	},
2361fa2a664SJoshua M. Clulow 	{ "pseudo", "^zcons/" ZONENAME_REGEXP "/(" ZCONS_MANAGER_NAME "|"
2371fa2a664SJoshua M. Clulow 		ZCONS_SUBSIDIARY_NAME ")$",
2387c478bd9Sstevel@tonic-gate 	    RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2397c478bd9Sstevel@tonic-gate 	},
240843e1988Sjohnlev 	{ "pseudo", "^" CPUID_SELF_NAME "$", RM_ALWAYS | RM_PRE | RM_HOT,
2417c478bd9Sstevel@tonic-gate 	    ILEVEL_0, devfsadm_rm_all
2427c478bd9Sstevel@tonic-gate 	},
2437c478bd9Sstevel@tonic-gate 	{ "enclosure", "^es/ses[0-9]+$", RM_POST,
2447c478bd9Sstevel@tonic-gate 		ILEVEL_0, devfsadm_rm_all
245edd26dc5Sdr 	},
246edd26dc5Sdr 	{ "pseudo", "^pfil$",
247edd26dc5Sdr 	    RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2488d26100cSWyllys Ingersoll 	},
2498d26100cSWyllys Ingersoll 	{ "pseudo", "^tpm$",
2508d26100cSWyllys Ingersoll 	    RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
2518d26100cSWyllys Ingersoll 	},
2525d41001aSGirish Moodalbail 	{ "pseudo", "^sctp|sctp6$",
2535d41001aSGirish Moodalbail 	    RM_PRE | RM_ALWAYS, ILEVEL_0, devfsadm_rm_link
25464439ec0SJoshua M. Clulow 	},
25564439ec0SJoshua M. Clulow 	{ "9p", "^9p/[0-9]+$",
25664439ec0SJoshua M. Clulow 	    RM_PRE | RM_HOT | RM_ALWAYS, ILEVEL_0, devfsadm_rm_all
25764439ec0SJoshua M. Clulow 	},
2587c478bd9Sstevel@tonic-gate };
2597c478bd9Sstevel@tonic-gate 
2607c478bd9Sstevel@tonic-gate /* Rules for gpio devices */
2617c478bd9Sstevel@tonic-gate static devfsadm_enumerate_t gpio_rules[1] =
2627c478bd9Sstevel@tonic-gate 	{"^gpio([0-9]+)$", 1, MATCH_ALL};
2637c478bd9Sstevel@tonic-gate 
2647c478bd9Sstevel@tonic-gate DEVFSADM_REMOVE_INIT_V0(misc_remove_cbt);
2657c478bd9Sstevel@tonic-gate 
2667c478bd9Sstevel@tonic-gate /*
2677c478bd9Sstevel@tonic-gate  * Handles minor node type "ddi_display".
2687c478bd9Sstevel@tonic-gate  *
2697c478bd9Sstevel@tonic-gate  * type=ddi_display fbs/\M0 fb\N0
2707c478bd9Sstevel@tonic-gate  */
2717c478bd9Sstevel@tonic-gate static int
display(di_minor_t minor,di_node_t node)2727c478bd9Sstevel@tonic-gate display(di_minor_t minor, di_node_t node)
2737c478bd9Sstevel@tonic-gate {
2747c478bd9Sstevel@tonic-gate 	char l_path[PATH_MAX + 1], contents[PATH_MAX + 1], *buf;
2757c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"^fb([0-9]+)$", 1, MATCH_ALL};
2767c478bd9Sstevel@tonic-gate 	char *mn = di_minor_name(minor);
2777c478bd9Sstevel@tonic-gate 
2787c478bd9Sstevel@tonic-gate 	/* create fbs/\M0 primary link */
2797c478bd9Sstevel@tonic-gate 	(void) strcpy(l_path, "fbs/");
2807c478bd9Sstevel@tonic-gate 	(void) strcat(l_path, mn);
2817c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(l_path, node, minor, 0);
2827c478bd9Sstevel@tonic-gate 
2837c478bd9Sstevel@tonic-gate 	/* create fb\N0 which links to fbs/\M0 */
2847c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(l_path, 0, &buf, rules, 1)) {
2857c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
2867c478bd9Sstevel@tonic-gate 	}
2877c478bd9Sstevel@tonic-gate 	(void) strcpy(contents, l_path);
2887c478bd9Sstevel@tonic-gate 	(void) strcpy(l_path, "fb");
2897c478bd9Sstevel@tonic-gate 	(void) strcat(l_path, buf);
2907c478bd9Sstevel@tonic-gate 	free(buf);
2917c478bd9Sstevel@tonic-gate 	(void) devfsadm_secondary_link(l_path, contents, 0);
2927c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
2937c478bd9Sstevel@tonic-gate }
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate /*
2967c478bd9Sstevel@tonic-gate  * Handles minor node type "ddi_parallel".
2977c478bd9Sstevel@tonic-gate  * type=ddi_parallel;name=mcpp     mcpp\N0
2987c478bd9Sstevel@tonic-gate  */
2997c478bd9Sstevel@tonic-gate static int
parallel(di_minor_t minor,di_node_t node)3007c478bd9Sstevel@tonic-gate parallel(di_minor_t minor, di_node_t node)
3017c478bd9Sstevel@tonic-gate {
3027c478bd9Sstevel@tonic-gate 	char path[PATH_MAX + 1], *buf;
3037c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"mcpp([0-9]+)$", 1, MATCH_ALL};
3047c478bd9Sstevel@tonic-gate 
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate 	if (strcmp(di_node_name(node), "mcpp") != 0) {
3077c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
3087c478bd9Sstevel@tonic-gate 	}
3097c478bd9Sstevel@tonic-gate 
3107c478bd9Sstevel@tonic-gate 	if (NULL == (buf = di_devfs_path(node))) {
3117c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
3127c478bd9Sstevel@tonic-gate 	}
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "%s:%s",
3157c478bd9Sstevel@tonic-gate 	    buf, di_minor_name(minor));
3167c478bd9Sstevel@tonic-gate 
3177c478bd9Sstevel@tonic-gate 	di_devfs_path_free(buf);
3187c478bd9Sstevel@tonic-gate 
3197c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
3207c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
3217c478bd9Sstevel@tonic-gate 	}
3227c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "mcpp%s", buf);
3237c478bd9Sstevel@tonic-gate 	free(buf);
3247c478bd9Sstevel@tonic-gate 
3257c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
3267c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate static int
ses_callback(di_minor_t minor,di_node_t node)3307c478bd9Sstevel@tonic-gate ses_callback(di_minor_t minor, di_node_t node)
3317c478bd9Sstevel@tonic-gate {
3327c478bd9Sstevel@tonic-gate 	char l_path[PATH_MAX];
3337c478bd9Sstevel@tonic-gate 	char *buf;
3347c478bd9Sstevel@tonic-gate 	char *devfspath;
3357c478bd9Sstevel@tonic-gate 	char p_path[PATH_MAX];
3367c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t re[] = {"^es$/^ses([0-9]+)$", 1, MATCH_ALL};
3377c478bd9Sstevel@tonic-gate 
3387c478bd9Sstevel@tonic-gate 	/* find devices path -- need to free mem */
3397c478bd9Sstevel@tonic-gate 	if (NULL == (devfspath = di_devfs_path(node))) {
3407c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
3417c478bd9Sstevel@tonic-gate 	}
3427c478bd9Sstevel@tonic-gate 
3437c478bd9Sstevel@tonic-gate 	(void) snprintf(p_path, sizeof (p_path), "%s:%s", devfspath,
3447c478bd9Sstevel@tonic-gate 	    di_minor_name(minor));
3457c478bd9Sstevel@tonic-gate 
3467c478bd9Sstevel@tonic-gate 
3477c478bd9Sstevel@tonic-gate 	/* find next number to use; buf is an ascii number */
3487c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(p_path, 0, &buf, re, 1)) {
3497c478bd9Sstevel@tonic-gate 		/* free memory */
3507c478bd9Sstevel@tonic-gate 		di_devfs_path_free(devfspath);
3517c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
3527c478bd9Sstevel@tonic-gate 	}
3537c478bd9Sstevel@tonic-gate 
3547c478bd9Sstevel@tonic-gate 	(void) snprintf(l_path, sizeof (l_path), "es/ses%s", buf);
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(l_path, node, minor, 0);
3577c478bd9Sstevel@tonic-gate 	/* free memory */
3587c478bd9Sstevel@tonic-gate 	free(buf);
3597c478bd9Sstevel@tonic-gate 	di_devfs_path_free(devfspath);
3607c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3617c478bd9Sstevel@tonic-gate 
3627c478bd9Sstevel@tonic-gate }
3637c478bd9Sstevel@tonic-gate 
3647c478bd9Sstevel@tonic-gate static int
node_slash_minor(di_minor_t minor,di_node_t node)3657c478bd9Sstevel@tonic-gate node_slash_minor(di_minor_t minor, di_node_t node)
3667c478bd9Sstevel@tonic-gate {
3677c478bd9Sstevel@tonic-gate 
3687c478bd9Sstevel@tonic-gate 	char path[PATH_MAX + 1];
3697c478bd9Sstevel@tonic-gate 
3707c478bd9Sstevel@tonic-gate 	(void) strcpy(path, di_node_name(node));
3717c478bd9Sstevel@tonic-gate 	(void) strcat(path, "/");
3727c478bd9Sstevel@tonic-gate 	(void) strcat(path, di_minor_name(minor));
3737c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
3747c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3757c478bd9Sstevel@tonic-gate }
3767c478bd9Sstevel@tonic-gate 
3777c478bd9Sstevel@tonic-gate static int
driver_minor(di_minor_t minor,di_node_t node)3787c478bd9Sstevel@tonic-gate driver_minor(di_minor_t minor, di_node_t node)
3797c478bd9Sstevel@tonic-gate {
3807c478bd9Sstevel@tonic-gate 	char path[PATH_MAX + 1];
3817c478bd9Sstevel@tonic-gate 
3827c478bd9Sstevel@tonic-gate 	(void) strcpy(path, di_driver_name(node));
3837c478bd9Sstevel@tonic-gate 	(void) strcat(path, di_minor_name(minor));
3847c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
3857c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3867c478bd9Sstevel@tonic-gate }
3877c478bd9Sstevel@tonic-gate 
3887c478bd9Sstevel@tonic-gate /*
3897c478bd9Sstevel@tonic-gate  * Handles links of the form:
3907c478bd9Sstevel@tonic-gate  * type=ddi_pseudo;name=xyz  \D
3917c478bd9Sstevel@tonic-gate  */
3927c478bd9Sstevel@tonic-gate static int
node_name(di_minor_t minor,di_node_t node)3937c478bd9Sstevel@tonic-gate node_name(di_minor_t minor, di_node_t node)
3947c478bd9Sstevel@tonic-gate {
3957c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(di_node_name(node), node, minor, 0);
3967c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
3977c478bd9Sstevel@tonic-gate }
3987c478bd9Sstevel@tonic-gate 
3997c478bd9Sstevel@tonic-gate /*
4007c478bd9Sstevel@tonic-gate  * Handles links of the form:
4017c478bd9Sstevel@tonic-gate  * type=ddi_pseudo;name=xyz  \M0
4027c478bd9Sstevel@tonic-gate  */
4037c478bd9Sstevel@tonic-gate static int
minor_name(di_minor_t minor,di_node_t node)4047c478bd9Sstevel@tonic-gate minor_name(di_minor_t minor, di_node_t node)
4057c478bd9Sstevel@tonic-gate {
4067c478bd9Sstevel@tonic-gate 	char *mn = di_minor_name(minor);
4077c478bd9Sstevel@tonic-gate 
4087c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(mn, node, minor, 0);
4097c478bd9Sstevel@tonic-gate 	if (strcmp(mn, "icmp") == 0) {
4107c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("rawip", node, minor, 0);
4117c478bd9Sstevel@tonic-gate 	}
4127c478bd9Sstevel@tonic-gate 	if (strcmp(mn, "icmp6") == 0) {
4137c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("rawip6", node, minor, 0);
4147c478bd9Sstevel@tonic-gate 	}
4157c478bd9Sstevel@tonic-gate 	if (strcmp(mn, "ipf") == 0) {
4167c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("ipl", node, minor, 0);
4177c478bd9Sstevel@tonic-gate 	}
4187c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
4197c478bd9Sstevel@tonic-gate }
4207c478bd9Sstevel@tonic-gate 
421516fc7f3Shx /*
422516fc7f3Shx  * create links at /dev/wifi for wifi minor node
423516fc7f3Shx  */
424516fc7f3Shx static int
wifi_minor_name(di_minor_t minor,di_node_t node)425516fc7f3Shx wifi_minor_name(di_minor_t minor, di_node_t node)
426516fc7f3Shx {
427516fc7f3Shx 	char buf[256];
428516fc7f3Shx 	char *mn = di_minor_name(minor);
429516fc7f3Shx 
430516fc7f3Shx 	(void) snprintf(buf, sizeof (buf), "%s%s", "wifi/", mn);
431516fc7f3Shx 	(void) devfsadm_mklink(buf, node, minor, 0);
432516fc7f3Shx 
433516fc7f3Shx 	return (DEVFSADM_CONTINUE);
434516fc7f3Shx }
4357c478bd9Sstevel@tonic-gate 
4367c478bd9Sstevel@tonic-gate static int
conskbd(di_minor_t minor,di_node_t node)4377c478bd9Sstevel@tonic-gate conskbd(di_minor_t minor, di_node_t node)
4387c478bd9Sstevel@tonic-gate {
4397c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink("kbd", node, minor, 0);
4407c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
4417c478bd9Sstevel@tonic-gate }
4427c478bd9Sstevel@tonic-gate 
4437c478bd9Sstevel@tonic-gate static int
consms(di_minor_t minor,di_node_t node)4447c478bd9Sstevel@tonic-gate consms(di_minor_t minor, di_node_t node)
4457c478bd9Sstevel@tonic-gate {
4467c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink("mouse", node, minor, 0);
4477c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
4487c478bd9Sstevel@tonic-gate }
4497c478bd9Sstevel@tonic-gate 
4507c478bd9Sstevel@tonic-gate static int
power_button(di_minor_t minor,di_node_t node)4517c478bd9Sstevel@tonic-gate power_button(di_minor_t minor, di_node_t node)
4527c478bd9Sstevel@tonic-gate {
4537c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink("power_button", node, minor, 0);
4547c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
4557c478bd9Sstevel@tonic-gate }
4567c478bd9Sstevel@tonic-gate 
4577c478bd9Sstevel@tonic-gate static int
fc_port(di_minor_t minor,di_node_t node)4587c478bd9Sstevel@tonic-gate fc_port(di_minor_t minor, di_node_t node)
4597c478bd9Sstevel@tonic-gate {
4607c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"fc/fp([0-9]+)$", 1, MATCH_ALL};
4617c478bd9Sstevel@tonic-gate 	char *buf, path[PATH_MAX + 1];
4627c478bd9Sstevel@tonic-gate 	char *ptr;
4637c478bd9Sstevel@tonic-gate 
4647c478bd9Sstevel@tonic-gate 	if (NULL == (ptr = di_devfs_path(node))) {
4657c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
4667c478bd9Sstevel@tonic-gate 	}
4677c478bd9Sstevel@tonic-gate 
4687c478bd9Sstevel@tonic-gate 	(void) strcpy(path, ptr);
4697c478bd9Sstevel@tonic-gate 	(void) strcat(path, ":");
4707c478bd9Sstevel@tonic-gate 	(void) strcat(path, di_minor_name(minor));
4717c478bd9Sstevel@tonic-gate 
4727c478bd9Sstevel@tonic-gate 	di_devfs_path_free(ptr);
4737c478bd9Sstevel@tonic-gate 
4747c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(path, 0, &buf, rules, 1) != 0) {
4757c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
4767c478bd9Sstevel@tonic-gate 	}
4777c478bd9Sstevel@tonic-gate 
4787c478bd9Sstevel@tonic-gate 	(void) strcpy(path, "fc/fp");
4797c478bd9Sstevel@tonic-gate 	(void) strcat(path, buf);
4807c478bd9Sstevel@tonic-gate 	free(buf);
4817c478bd9Sstevel@tonic-gate 
4827c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
4837c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
4847c478bd9Sstevel@tonic-gate }
4857c478bd9Sstevel@tonic-gate 
4867c478bd9Sstevel@tonic-gate /*
4877c478bd9Sstevel@tonic-gate  * Handles:
4887c478bd9Sstevel@tonic-gate  *	minor node type "ddi_printer".
4891fa2a664SJoshua M. Clulow  *	rules of the form: type=ddi_printer;name=bpp  \M0
4907c478bd9Sstevel@tonic-gate  */
4917c478bd9Sstevel@tonic-gate static int
printer_create(di_minor_t minor,di_node_t node)4927c478bd9Sstevel@tonic-gate printer_create(di_minor_t minor, di_node_t node)
4937c478bd9Sstevel@tonic-gate {
4947c478bd9Sstevel@tonic-gate 	char *mn;
4957c478bd9Sstevel@tonic-gate 	char path[PATH_MAX + 1], *buf;
4967c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"^printers$/^([0-9]+)$", 1, MATCH_ALL};
4977c478bd9Sstevel@tonic-gate 
4987c478bd9Sstevel@tonic-gate 	mn = di_minor_name(minor);
4997c478bd9Sstevel@tonic-gate 
5007c478bd9Sstevel@tonic-gate 	if (strcmp(di_driver_name(node), "bpp") == 0) {
5017c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink(mn, node, minor, 0);
5027c478bd9Sstevel@tonic-gate 	}
5037c478bd9Sstevel@tonic-gate 
5047c478bd9Sstevel@tonic-gate 	if (NULL == (buf = di_devfs_path(node))) {
5057c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5067c478bd9Sstevel@tonic-gate 	}
5077c478bd9Sstevel@tonic-gate 
5087c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "%s:%s", buf, mn);
5097c478bd9Sstevel@tonic-gate 	di_devfs_path_free(buf);
5107c478bd9Sstevel@tonic-gate 
5117c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
5127c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5137c478bd9Sstevel@tonic-gate 	}
5147c478bd9Sstevel@tonic-gate 
5157c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "printers/%s", buf);
5167c478bd9Sstevel@tonic-gate 	free(buf);
5177c478bd9Sstevel@tonic-gate 
5187c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
5197c478bd9Sstevel@tonic-gate 
5207c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
5217c478bd9Sstevel@tonic-gate }
5227c478bd9Sstevel@tonic-gate 
5237c478bd9Sstevel@tonic-gate /*
5247c478bd9Sstevel@tonic-gate  * Handles links of the form:
5257c478bd9Sstevel@tonic-gate  * type=ddi_pseudo;name=se;minor2=hdlc	se_hdlc\N0
5267c478bd9Sstevel@tonic-gate  * type=ddi_pseudo;name=serial;minor2=hdlc	se_hdlc\N0
5277c478bd9Sstevel@tonic-gate  */
5287c478bd9Sstevel@tonic-gate static int
se_hdlc_create(di_minor_t minor,di_node_t node)5297c478bd9Sstevel@tonic-gate se_hdlc_create(di_minor_t minor, di_node_t node)
5307c478bd9Sstevel@tonic-gate {
5317c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"^se_hdlc([0-9]+)$", 1, MATCH_ALL};
5327c478bd9Sstevel@tonic-gate 	char *buf, path[PATH_MAX + 1];
5337c478bd9Sstevel@tonic-gate 	char *ptr;
5347c478bd9Sstevel@tonic-gate 	char *mn;
5357c478bd9Sstevel@tonic-gate 
5367c478bd9Sstevel@tonic-gate 	mn = di_minor_name(minor);
5377c478bd9Sstevel@tonic-gate 
5387c478bd9Sstevel@tonic-gate 	/* minor node should be of the form: "?,hdlc" */
5397c478bd9Sstevel@tonic-gate 	if (strcmp(mn + 1, ",hdlc") != 0) {
5407c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5417c478bd9Sstevel@tonic-gate 	}
5427c478bd9Sstevel@tonic-gate 
5437c478bd9Sstevel@tonic-gate 	if (NULL == (ptr = di_devfs_path(node))) {
5447c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5457c478bd9Sstevel@tonic-gate 	}
5467c478bd9Sstevel@tonic-gate 
5477c478bd9Sstevel@tonic-gate 	(void) strcpy(path, ptr);
5487c478bd9Sstevel@tonic-gate 	(void) strcat(path, ":");
5497c478bd9Sstevel@tonic-gate 	(void) strcat(path, mn);
5507c478bd9Sstevel@tonic-gate 
5517c478bd9Sstevel@tonic-gate 	di_devfs_path_free(ptr);
5527c478bd9Sstevel@tonic-gate 
5537c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(path, 0, &buf, rules, 1) != 0) {
5547c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5557c478bd9Sstevel@tonic-gate 	}
5567c478bd9Sstevel@tonic-gate 
5577c478bd9Sstevel@tonic-gate 	(void) strcpy(path, "se_hdlc");
5587c478bd9Sstevel@tonic-gate 	(void) strcat(path, buf);
5597c478bd9Sstevel@tonic-gate 	free(buf);
5607c478bd9Sstevel@tonic-gate 
5617c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
5627c478bd9Sstevel@tonic-gate 
5637c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
5647c478bd9Sstevel@tonic-gate }
5657c478bd9Sstevel@tonic-gate 
5667c478bd9Sstevel@tonic-gate static int
gpio(di_minor_t minor,di_node_t node)5677c478bd9Sstevel@tonic-gate gpio(di_minor_t minor, di_node_t node)
5687c478bd9Sstevel@tonic-gate {
5697c478bd9Sstevel@tonic-gate 	char l_path[PATH_MAX], p_path[PATH_MAX], *buf, *devfspath;
5707c478bd9Sstevel@tonic-gate 	char *minor_nm, *drvr_nm;
5717c478bd9Sstevel@tonic-gate 
5727c478bd9Sstevel@tonic-gate 
5737c478bd9Sstevel@tonic-gate 	minor_nm = di_minor_name(minor);
5747c478bd9Sstevel@tonic-gate 	drvr_nm = di_driver_name(node);
5757c478bd9Sstevel@tonic-gate 	if ((minor_nm == NULL) || (drvr_nm == NULL)) {
5767c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5777c478bd9Sstevel@tonic-gate 	}
5787c478bd9Sstevel@tonic-gate 
5797c478bd9Sstevel@tonic-gate 	devfspath = di_devfs_path(node);
5807c478bd9Sstevel@tonic-gate 
5817c478bd9Sstevel@tonic-gate 	(void) strcpy(p_path, devfspath);
5827c478bd9Sstevel@tonic-gate 	(void) strcat(p_path, ":");
5837c478bd9Sstevel@tonic-gate 	(void) strcat(p_path, minor_nm);
5847c478bd9Sstevel@tonic-gate 	di_devfs_path_free(devfspath);
5857c478bd9Sstevel@tonic-gate 
5867c478bd9Sstevel@tonic-gate 	/* build the physical path from the components */
5877c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(p_path, 0, &buf, gpio_rules, 1)) {
5887c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
5897c478bd9Sstevel@tonic-gate 	}
5907c478bd9Sstevel@tonic-gate 
5917c478bd9Sstevel@tonic-gate 	(void) snprintf(l_path, sizeof (l_path), "%s%s", "gpio", buf);
5927c478bd9Sstevel@tonic-gate 
5937c478bd9Sstevel@tonic-gate 	free(buf);
5947c478bd9Sstevel@tonic-gate 
5957c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(l_path, node, minor, 0);
5967c478bd9Sstevel@tonic-gate 
5977c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
5987c478bd9Sstevel@tonic-gate }
5997c478bd9Sstevel@tonic-gate 
6007c478bd9Sstevel@tonic-gate /*
6017c478bd9Sstevel@tonic-gate  * Creates /dev/ppm nodes for Platform Specific PM module
6027c478bd9Sstevel@tonic-gate  */
6037c478bd9Sstevel@tonic-gate static int
ppm(di_minor_t minor,di_node_t node)6047c478bd9Sstevel@tonic-gate ppm(di_minor_t minor, di_node_t node)
6057c478bd9Sstevel@tonic-gate {
6067c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink("ppm", node, minor, 0);
6077c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
6087c478bd9Sstevel@tonic-gate }
6097c478bd9Sstevel@tonic-gate 
6107c478bd9Sstevel@tonic-gate /*
6117c478bd9Sstevel@tonic-gate  * Handles:
6127c478bd9Sstevel@tonic-gate  *	/dev/av/[0-9]+/(async|isoch)
6137c478bd9Sstevel@tonic-gate  */
6147c478bd9Sstevel@tonic-gate static int
av_create(di_minor_t minor,di_node_t node)6157c478bd9Sstevel@tonic-gate av_create(di_minor_t minor, di_node_t node)
6167c478bd9Sstevel@tonic-gate {
6177c478bd9Sstevel@tonic-gate 	devfsadm_enumerate_t rules[1] = {"^av$/^([0-9]+)$", 1, MATCH_ADDR};
6187c478bd9Sstevel@tonic-gate 	char	*minor_str;
6197c478bd9Sstevel@tonic-gate 	char	path[PATH_MAX + 1];
6207c478bd9Sstevel@tonic-gate 	char	*buf;
6217c478bd9Sstevel@tonic-gate 
6227c478bd9Sstevel@tonic-gate 	if ((buf = di_devfs_path(node)) == NULL) {
6237c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
6247c478bd9Sstevel@tonic-gate 	}
6257c478bd9Sstevel@tonic-gate 
6267c478bd9Sstevel@tonic-gate 	minor_str = di_minor_name(minor);
6277c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "%s:%s", buf, minor_str);
6287c478bd9Sstevel@tonic-gate 	di_devfs_path_free(buf);
6297c478bd9Sstevel@tonic-gate 
6307c478bd9Sstevel@tonic-gate 	if (devfsadm_enumerate_int(path, 0, &buf, rules, 1)) {
6317c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
6327c478bd9Sstevel@tonic-gate 	}
6337c478bd9Sstevel@tonic-gate 
6347c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "av/%s/%s", buf, minor_str);
6357c478bd9Sstevel@tonic-gate 	free(buf);
6367c478bd9Sstevel@tonic-gate 
6377c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
6387c478bd9Sstevel@tonic-gate 
6397c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
6407c478bd9Sstevel@tonic-gate }
6417c478bd9Sstevel@tonic-gate 
64264439ec0SJoshua M. Clulow /*
64364439ec0SJoshua M. Clulow  * Create device nodes for Virtio 9P channels:
64464439ec0SJoshua M. Clulow  *	/dev/9p/[0-9]+
64564439ec0SJoshua M. Clulow  */
64664439ec0SJoshua M. Clulow static int
vio9p_create(di_minor_t minor,di_node_t node)64764439ec0SJoshua M. Clulow vio9p_create(di_minor_t minor, di_node_t node)
64864439ec0SJoshua M. Clulow {
64964439ec0SJoshua M. Clulow 	char *minor_name = di_minor_name(minor);
65064439ec0SJoshua M. Clulow 	char path[PATH_MAX + 1];
65164439ec0SJoshua M. Clulow 
65264439ec0SJoshua M. Clulow 	if (minor_name == NULL || strcmp(minor_name, "9p") != 0) {
65364439ec0SJoshua M. Clulow 		return (DEVFSADM_CONTINUE);
65464439ec0SJoshua M. Clulow 	}
65564439ec0SJoshua M. Clulow 
65664439ec0SJoshua M. Clulow 	(void) snprintf(path, sizeof (path), "9p/%d", di_instance(node));
65764439ec0SJoshua M. Clulow 	(void) devfsadm_mklink(path, node, minor, 0);
65864439ec0SJoshua M. Clulow 
65964439ec0SJoshua M. Clulow 	return (DEVFSADM_CONTINUE);
66064439ec0SJoshua M. Clulow }
66164439ec0SJoshua M. Clulow 
6627c478bd9Sstevel@tonic-gate /*
6637c478bd9Sstevel@tonic-gate  * Creates /dev/lom and /dev/tsalarm:ctl for tsalarm node
6647c478bd9Sstevel@tonic-gate  */
6657c478bd9Sstevel@tonic-gate static int
tsalarm_create(di_minor_t minor,di_node_t node)6667c478bd9Sstevel@tonic-gate tsalarm_create(di_minor_t minor, di_node_t node)
6677c478bd9Sstevel@tonic-gate {
6687c478bd9Sstevel@tonic-gate 	char buf[PATH_MAX + 1];
6697c478bd9Sstevel@tonic-gate 	char *mn = di_minor_name(minor);
6707c478bd9Sstevel@tonic-gate 
6717c478bd9Sstevel@tonic-gate 	(void) snprintf(buf, sizeof (buf), "%s%s", di_node_name(node), ":ctl");
6727c478bd9Sstevel@tonic-gate 
6737c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(mn, node, minor, 0);
6747c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(buf, node, minor, 0);
6757c478bd9Sstevel@tonic-gate 
6767c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
677e3f8e17dSsc }
678e3f8e17dSsc 
679e3f8e17dSsc /*
680e3f8e17dSsc  * Creates /dev/ntwdt for ntwdt node
681e3f8e17dSsc  */
682e3f8e17dSsc static int
ntwdt_create(di_minor_t minor,di_node_t node)683e3f8e17dSsc ntwdt_create(di_minor_t minor, di_node_t node)
684e3f8e17dSsc {
685e3f8e17dSsc 	(void) devfsadm_mklink("ntwdt", node, minor, 0);
686e3f8e17dSsc 	return (DEVFSADM_CONTINUE);
6877c478bd9Sstevel@tonic-gate }
6887c478bd9Sstevel@tonic-gate 
6897c478bd9Sstevel@tonic-gate static int
zcons_create(di_minor_t minor,di_node_t node)6907c478bd9Sstevel@tonic-gate zcons_create(di_minor_t minor, di_node_t node)
6917c478bd9Sstevel@tonic-gate {
6927c478bd9Sstevel@tonic-gate 	char	*minor_str;
6937c478bd9Sstevel@tonic-gate 	char	*zonename;
6947c478bd9Sstevel@tonic-gate 	char	path[MAXPATHLEN];
6957c478bd9Sstevel@tonic-gate 
6967c478bd9Sstevel@tonic-gate 	minor_str = di_minor_name(minor);
6977c478bd9Sstevel@tonic-gate 
6987c478bd9Sstevel@tonic-gate 	if (di_prop_lookup_strings(DDI_DEV_T_ANY, node, "zonename",
6997c478bd9Sstevel@tonic-gate 	    &zonename) == -1) {
7007c478bd9Sstevel@tonic-gate 		return (DEVFSADM_CONTINUE);
7017c478bd9Sstevel@tonic-gate 	}
7027c478bd9Sstevel@tonic-gate 
7037c478bd9Sstevel@tonic-gate 	(void) snprintf(path, sizeof (path), "zcons/%s/%s", zonename,
7047c478bd9Sstevel@tonic-gate 	    minor_str);
7057c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(path, node, minor, 0);
7067c478bd9Sstevel@tonic-gate 
7077c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
7087c478bd9Sstevel@tonic-gate }
7097c478bd9Sstevel@tonic-gate 
7107c478bd9Sstevel@tonic-gate /*
7111fa2a664SJoshua M. Clulow  *	/dev/cpu/self/cpuid	->	/devices/pseudo/cpuid@0:self
7127c478bd9Sstevel@tonic-gate  */
7137c478bd9Sstevel@tonic-gate static int
cpuid(di_minor_t minor,di_node_t node)7147c478bd9Sstevel@tonic-gate cpuid(di_minor_t minor, di_node_t node)
7157c478bd9Sstevel@tonic-gate {
7167c478bd9Sstevel@tonic-gate 	(void) devfsadm_mklink(CPUID_SELF_NAME, node, minor, 0);
7177c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
7187c478bd9Sstevel@tonic-gate }
7197c478bd9Sstevel@tonic-gate 
7207c478bd9Sstevel@tonic-gate /*
7217c478bd9Sstevel@tonic-gate  * For device
7227c478bd9Sstevel@tonic-gate  *      /dev/spfma -> /devices/virtual-devices/fma@5:glvc
7237c478bd9Sstevel@tonic-gate  */
7247c478bd9Sstevel@tonic-gate static int
glvc(di_minor_t minor,di_node_t node)7257c478bd9Sstevel@tonic-gate glvc(di_minor_t minor, di_node_t node)
7267c478bd9Sstevel@tonic-gate {
7277c478bd9Sstevel@tonic-gate 	char node_name[MAXNAMELEN + 1];
7287c478bd9Sstevel@tonic-gate 
7297c478bd9Sstevel@tonic-gate 	(void) strcpy(node_name, di_node_name(node));
7307c478bd9Sstevel@tonic-gate 
7317c478bd9Sstevel@tonic-gate 	if (strncmp(node_name, "fma", 3) == 0) {
7327c478bd9Sstevel@tonic-gate 		/* Only one fma channel */
7337c478bd9Sstevel@tonic-gate 		(void) devfsadm_mklink("spfma", node, minor, 0);
7347c478bd9Sstevel@tonic-gate 	}
7357c478bd9Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
7367c478bd9Sstevel@tonic-gate }
73725cf1a30Sjl 
73825cf1a30Sjl /*
73925cf1a30Sjl  * Handles links of the form:
74025cf1a30Sjl  * type=ddi_pseudo;name=sckmdrv		kmdrv\M0
74125cf1a30Sjl  * type=ddi_pseudo;name=oplkmdrv	kmdrv\M0
74225cf1a30Sjl  */
74325cf1a30Sjl static int
kmdrv_create(di_minor_t minor,di_node_t node)74425cf1a30Sjl kmdrv_create(di_minor_t minor, di_node_t node)
74525cf1a30Sjl {
74625cf1a30Sjl 
74725cf1a30Sjl 	(void) devfsadm_mklink("kmdrv", node, minor, 0);
74825cf1a30Sjl 	return (DEVFSADM_CONTINUE);
74925cf1a30Sjl }
750