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 5*b9e93c10SJonathan Haslam * Common Development and Distribution License (the "License"). 6*b9e93c10SJonathan Haslam * 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 /* 22*b9e93c10SJonathan Haslam * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #include <devfsadm.h> 277c478bd9Sstevel@tonic-gate #include <strings.h> 28fb405578Sdp #include <stdio.h> 297c478bd9Sstevel@tonic-gate #include <sys/dtrace.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate static int dtrace(di_minor_t minor, di_node_t node); 32fb405578Sdp static int dtrace_provider(di_minor_t minor, di_node_t node); 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate static devfsadm_create_t dtrace_create_cbt[] = { 357c478bd9Sstevel@tonic-gate { "pseudo", "ddi_pseudo", "dtrace", 36fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace }, 37fb405578Sdp { "pseudo", "ddi_pseudo", "fasttrap", 38fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 39fb405578Sdp { "pseudo", "ddi_pseudo", "fbt", 40fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 41fb405578Sdp { "pseudo", "ddi_pseudo", "lockstat", 42fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 43fb405578Sdp { "pseudo", "ddi_pseudo", "profile", 44fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 45fb405578Sdp { "pseudo", "ddi_pseudo", "sdt", 46fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 47fb405578Sdp { "pseudo", "ddi_pseudo", "systrace", 48fb405578Sdp TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 49*b9e93c10SJonathan Haslam { "pseudo", "ddi_pseudo", "dcpc", 50*b9e93c10SJonathan Haslam TYPE_EXACT | DRV_EXACT, ILEVEL_0, dtrace_provider }, 517c478bd9Sstevel@tonic-gate }; 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate DEVFSADM_CREATE_INIT_V0(dtrace_create_cbt); 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate static int 567c478bd9Sstevel@tonic-gate dtrace(di_minor_t minor, di_node_t node) 577c478bd9Sstevel@tonic-gate { 587c478bd9Sstevel@tonic-gate char *mname = di_minor_name(minor); 59fb405578Sdp char path[MAXPATHLEN]; 607c478bd9Sstevel@tonic-gate 61fb405578Sdp (void) snprintf(path, sizeof (path), "dtrace/%s", mname); 62fb405578Sdp (void) devfsadm_mklink(path, node, minor, 0); 63fb405578Sdp 64fb405578Sdp return (DEVFSADM_CONTINUE); 657c478bd9Sstevel@tonic-gate } 667c478bd9Sstevel@tonic-gate 67fb405578Sdp static int 68fb405578Sdp dtrace_provider(di_minor_t minor, di_node_t node) 69fb405578Sdp { 70fb405578Sdp char *mname = di_minor_name(minor); 71fb405578Sdp char path[MAXPATHLEN]; 72fb405578Sdp 73fb405578Sdp (void) snprintf(path, sizeof (path), "dtrace/provider/%s", mname); 74fb405578Sdp (void) devfsadm_mklink(path, node, minor, 0); 75fb405578Sdp 767c478bd9Sstevel@tonic-gate return (DEVFSADM_CONTINUE); 777c478bd9Sstevel@tonic-gate } 78