Path: blob/main/sys/cddl/dev/dtrace/dtrace_sysctl.c
48254 views
/*1* CDDL HEADER START2*3* The contents of this file are subject to the terms of the4* Common Development and Distribution License (the "License").5* You may not use this file except in compliance with the License.6*7* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE8* or http://www.opensolaris.org/os/licensing.9* See the License for the specific language governing permissions10* and limitations under the License.11*12* When distributing Covered Code, include this CDDL HEADER in each13* file and include the License file at usr/src/OPENSOLARIS.LICENSE.14* If applicable, add the following below this CDDL HEADER, with the15* fields enclosed by brackets "[]" replaced with your own identifying16* information: Portions Copyright [yyyy] [name of copyright owner]17*18* CDDL HEADER END19*20*/2122/* Report registered DTrace providers. */23static int24sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)25{26char *p_name = NULL;27dtrace_provider_t28*prov = dtrace_provider;29int error = 0;30size_t len = 0;3132mutex_enter(&dtrace_provider_lock);33mutex_enter(&dtrace_lock);3435/* Compute the length of the space-separated provider name string. */36while (prov != NULL) {37len += strlen(prov->dtpv_name) + 1;38prov = prov->dtpv_next;39}4041if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)42error = ENOMEM;43else {44/* Start with an empty string. */45*p_name = '\0';4647/* Point to the first provider again. */48prov = dtrace_provider;4950/* Loop through the providers, appending the names. */51while (prov != NULL) {52if (prov != dtrace_provider)53(void) strlcat(p_name, " ", len);5455(void) strlcat(p_name, prov->dtpv_name, len);5657prov = prov->dtpv_next;58}59}6061mutex_exit(&dtrace_lock);62mutex_exit(&dtrace_provider_lock);6364if (p_name != NULL) {65error = sysctl_handle_string(oidp, p_name, len, req);6667kmem_free(p_name, 0);68}6970return (error);71}7273SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,74"DTrace debug parameters");7576SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers,77CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers,78"A", "available DTrace providers");7980SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,81"DTrace parameters");8283SYSCTL_INT(_kern_dtrace, OID_AUTO, err_verbose, CTLFLAG_RW,84&dtrace_err_verbose, 0,85"print DIF and DOF validation errors to the message buffer");8687SYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max,880, "largest allowed argument to memstr(), 0 indicates no limit");8990SYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,91&dtrace_dof_maxsize, 0, "largest allowed DOF table");9293SYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,94&dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");9596SYSCTL_INT(_kern_dtrace, OID_AUTO, bufsize_max, CTLFLAG_RWTUN,97&dtrace_bufsize_max_frac, 0,98"maximum fraction (1/n-th) of physical memory for principal buffers");99100SYSCTL_INT(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN,101&dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts");102103104