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