1/* $NetBSD: dtrace_sysctl.c,v 1.4 2018/05/28 21:05:03 chs 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: head/sys/cddl/dev/dtrace/dtrace_sysctl.c 309069 2016-11-23 22:50:20Z gnn $ 24 * 25 */ 26 27#if 0 /* XXX TBD sysctl */ 28/* Report registered DTrace providers. */ 29static int 30sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) 31{ 32 char *p_name = NULL; 33 dtrace_provider_t 34 *prov = dtrace_provider; 35 int error = 0; 36 size_t len = 0; 37 38 mutex_enter(&dtrace_provider_lock); 39 mutex_enter(&dtrace_lock); 40 41 /* Compute the length of the space-separated provider name string. */ 42 while (prov != NULL) { 43 len += strlen(prov->dtpv_name) + 1; 44 prov = prov->dtpv_next; 45 } 46 47 if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL) 48 error = ENOMEM; 49 else { 50 /* Start with an empty string. */ 51 *p_name = '\0'; 52 53 /* Point to the first provider again. */ 54 prov = dtrace_provider; 55 56 /* Loop through the providers, appending the names. */ 57 while (prov != NULL) { 58 if (prov != dtrace_provider) 59 (void) strlcat(p_name, " ", len); 60 61 (void) strlcat(p_name, prov->dtpv_name, len); 62 63 prov = prov->dtpv_next; 64 } 65 } 66 67 mutex_exit(&dtrace_lock); 68 mutex_exit(&dtrace_provider_lock); 69 70 if (p_name != NULL) { 71 error = sysctl_handle_string(oidp, p_name, len, req); 72 73 kmem_free(p_name, len); 74 } 75 76 return (error); 77} 78 79SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters"); 80 81SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD, 82 0, 0, sysctl_dtrace_providers, "A", "available DTrace providers"); 83 84SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace parameters"); 85 86SYSCTL_INT(_kern_dtrace, OID_AUTO, err_verbose, CTLFLAG_RW, 87 &dtrace_err_verbose, 0, 88 "print DIF and DOF validation errors to the message buffer"); 89 90SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max, 91 0, "largest allowed argument to memstr(), 0 indicates no limit"); 92 93SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW, 94 &dtrace_dof_maxsize, 0, "largest allowed DOF table"); 95 96SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW, 97 &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions"); 98 99SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN, 100 &dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts"); 101 102#endif 103