xref: /onnv-gate/usr/src/cmd/devfsadm/dtrace_link.c (revision 8803:8c01b39012c9)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*8803SJonathan.Haslam@Sun.COM  * Common Development and Distribution License (the "License").
6*8803SJonathan.Haslam@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*8803SJonathan.Haslam@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #include <devfsadm.h>
270Sstevel@tonic-gate #include <strings.h>
281149Sdp #include <stdio.h>
290Sstevel@tonic-gate #include <sys/dtrace.h>
300Sstevel@tonic-gate 
310Sstevel@tonic-gate static int dtrace(di_minor_t minor, di_node_t node);
321149Sdp static int dtrace_provider(di_minor_t minor, di_node_t node);
330Sstevel@tonic-gate 
340Sstevel@tonic-gate static devfsadm_create_t dtrace_create_cbt[] = {
350Sstevel@tonic-gate 	{ "pseudo", "ddi_pseudo", "dtrace",
361149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace },
371149Sdp 	{ "pseudo", "ddi_pseudo", "fasttrap",
381149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
391149Sdp 	{ "pseudo", "ddi_pseudo", "fbt",
401149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
411149Sdp 	{ "pseudo", "ddi_pseudo", "lockstat",
421149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
431149Sdp 	{ "pseudo", "ddi_pseudo", "profile",
441149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
451149Sdp 	{ "pseudo", "ddi_pseudo", "sdt",
461149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
471149Sdp 	{ "pseudo", "ddi_pseudo", "systrace",
481149Sdp 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
49*8803SJonathan.Haslam@Sun.COM 	{ "pseudo", "ddi_pseudo", "dcpc",
50*8803SJonathan.Haslam@Sun.COM 	    TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider },
510Sstevel@tonic-gate };
520Sstevel@tonic-gate 
530Sstevel@tonic-gate DEVFSADM_CREATE_INIT_V0(dtrace_create_cbt);
540Sstevel@tonic-gate 
550Sstevel@tonic-gate static int
dtrace(di_minor_t minor,di_node_t node)560Sstevel@tonic-gate dtrace(di_minor_t minor, di_node_t node)
570Sstevel@tonic-gate {
580Sstevel@tonic-gate 	char *mname = di_minor_name(minor);
591149Sdp 	char path[MAXPATHLEN];
600Sstevel@tonic-gate 
611149Sdp 	(void) snprintf(path, sizeof (path), "dtrace/%s", mname);
621149Sdp 	(void) devfsadm_mklink(path, node, minor, 0);
630Sstevel@tonic-gate 
640Sstevel@tonic-gate 	return (DEVFSADM_CONTINUE);
650Sstevel@tonic-gate }
661149Sdp 
671149Sdp static int
dtrace_provider(di_minor_t minor,di_node_t node)681149Sdp dtrace_provider(di_minor_t minor, di_node_t node)
691149Sdp {
701149Sdp 	char *mname = di_minor_name(minor);
711149Sdp 	char path[MAXPATHLEN];
721149Sdp 
731149Sdp 	(void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname);
741149Sdp 	(void) devfsadm_mklink(path, node, minor, 0);
751149Sdp 
761149Sdp 	return (DEVFSADM_CONTINUE);
771149Sdp }
78