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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * 21 */ 22 23 /* Report registered DTrace providers. */ 24 static int 25 sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) 26 { 27 char *p_name = NULL; 28 dtrace_provider_t 29 *prov = dtrace_provider; 30 int error = 0; 31 size_t len = 0; 32 33 mutex_enter(&dtrace_provider_lock); 34 mutex_enter(&dtrace_lock); 35 36 /* Compute the length of the space-separated provider name string. */ 37 while (prov != NULL) { 38 len += strlen(prov->dtpv_name) + 1; 39 prov = prov->dtpv_next; 40 } 41 42 if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL) 43 error = ENOMEM; 44 else { 45 /* Start with an empty string. */ 46 *p_name = '\0'; 47 48 /* Point to the first provider again. */ 49 prov = dtrace_provider; 50 51 /* Loop through the providers, appending the names. */ 52 while (prov != NULL) { 53 if (prov != dtrace_provider) 54 (void) strlcat(p_name, " ", len); 55 56 (void) strlcat(p_name, prov->dtpv_name, len); 57 58 prov = prov->dtpv_next; 59 } 60 } 61 62 mutex_exit(&dtrace_lock); 63 mutex_exit(&dtrace_provider_lock); 64 65 if (p_name != NULL) { 66 error = sysctl_handle_string(oidp, p_name, len, req); 67 68 kmem_free(p_name, 0); 69 } 70 71 return (error); 72 } 73 74 SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 75 "DTrace debug parameters"); 76 77 SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, 78 CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers, 79 "A", "available DTrace providers"); 80 81 SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, 82 "DTrace parameters"); 83 84 SYSCTL_INT(_kern_dtrace, OID_AUTO, err_verbose, CTLFLAG_RW, 85 &dtrace_err_verbose, 0, 86 "print DIF and DOF validation errors to the message buffer"); 87 88 SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max, 89 0, "largest allowed argument to memstr(), 0 indicates no limit"); 90 91 SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW, 92 &dtrace_dof_maxsize, 0, "largest allowed DOF table"); 93 94 SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW, 95 &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions"); 96 97 SYSCTL_INT(_kern_dtrace, OID_AUTO, bufsize_max, CTLFLAG_RWTUN, 98 &dtrace_bufsize_max_frac, 0, 99 "maximum fraction (1/n-th) of physical memory for principal buffers"); 100 101 SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN, 102 &dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts"); 103