1 /* $NetBSD: dtrace_sysctl.c,v 1.3 2010/04/23 11:39:52 ahoka Exp $ */ 2 3 /* 4 * CDDL HEADER START 5 * 6 * The contents of this file are subject to the terms of the 7 * Common Development and Distribution License (the "License"). 8 * You may not use this file except in compliance with the License. 9 * 10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 11 * or http://www.opensolaris.org/os/licensing. 12 * See the License for the specific language governing permissions 13 * and limitations under the License. 14 * 15 * When distributing Covered Code, include this CDDL HEADER in each 16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 17 * If applicable, add the following below this CDDL HEADER, with the 18 * fields enclosed by brackets "[]" replaced with your own identifying 19 * information: Portions Copyright [yyyy] [name of copyright owner] 20 * 21 * CDDL HEADER END 22 * 23 * $FreeBSD: src/sys/cddl/dev/dtrace/dtrace_sysctl.c,v 1.1.4.1 2009/08/03 08:13:06 kensmith Exp $ 24 * 25 */ 26 27 int dtrace_debug = 0; 28 #if 0 29 TUNABLE_INT("debug.dtrace.debug", &dtrace_debug); 30 SYSCTL_INT(_debug_dtrace, OID_AUTO, debug, CTLFLAG_RW, &dtrace_debug, 0, ""); 31 #endif 32 33 #if 0 /* XXX TBD sysctl */ 34 /* Report registered DTrace providers. */ 35 static int 36 sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) 37 { 38 char *p_name = NULL; 39 dtrace_provider_t 40 *prov = dtrace_provider; 41 int error = 0; 42 size_t len = 0; 43 44 mutex_enter(&dtrace_provider_lock); 45 mutex_enter(&dtrace_lock); 46 47 /* Compute the length of the space-separated provider name string. */ 48 while (prov != NULL) { 49 len += strlen(prov->dtpv_name) + 1; 50 prov = prov->dtpv_next; 51 } 52 53 if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL) 54 error = ENOMEM; 55 else { 56 /* Start with an empty string. */ 57 *p_name = '\0'; 58 59 /* Point to the first provider again. */ 60 prov = dtrace_provider; 61 62 /* Loop through the providers, appending the names. */ 63 while (prov != NULL) { 64 if (prov != dtrace_provider) 65 (void) strlcat(p_name, " ", len); 66 67 (void) strlcat(p_name, prov->dtpv_name, len); 68 69 prov = prov->dtpv_next; 70 } 71 } 72 73 mutex_exit(&dtrace_lock); 74 mutex_exit(&dtrace_provider_lock); 75 76 if (p_name != NULL) { 77 error = sysctl_handle_string(oidp, p_name, len, req); 78 79 kmem_free(p_name, len); 80 } 81 82 return (error); 83 } 84 85 SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, 86 0, 0, sysctl_dtrace_providers, "A", ""); 87 #endif 88