1179237Sjb/*
2179237Sjb * CDDL HEADER START
3179237Sjb *
4179237Sjb * The contents of this file are subject to the terms of the
5179237Sjb * Common Development and Distribution License (the "License").
6179237Sjb * You may not use this file except in compliance with the License.
7179237Sjb *
8179237Sjb * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9179237Sjb * or http://www.opensolaris.org/os/licensing.
10179237Sjb * See the License for the specific language governing permissions
11179237Sjb * and limitations under the License.
12179237Sjb *
13179237Sjb * When distributing Covered Code, include this CDDL HEADER in each
14179237Sjb * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15179237Sjb * If applicable, add the following below this CDDL HEADER, with the
16179237Sjb * fields enclosed by brackets "[]" replaced with your own identifying
17179237Sjb * information: Portions Copyright [yyyy] [name of copyright owner]
18179237Sjb *
19179237Sjb * CDDL HEADER END
20179237Sjb *
21179237Sjb * $FreeBSD: releng/11.0/sys/cddl/dev/dtrace/dtrace_sysctl.c 298587 2016-04-25 18:09:36Z markj $
22179237Sjb *
23179237Sjb */
24179237Sjb
25179237Sjb/* Report registered DTrace providers. */
26179237Sjbstatic int
27179237Sjbsysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
28179237Sjb{
29179237Sjb	char	*p_name	= NULL;
30179237Sjb	dtrace_provider_t
31179237Sjb		*prov	= dtrace_provider;
32179237Sjb	int	error	= 0;
33179237Sjb	size_t	len	= 0;
34179237Sjb
35179237Sjb	mutex_enter(&dtrace_provider_lock);
36179237Sjb	mutex_enter(&dtrace_lock);
37179237Sjb
38179237Sjb	/* Compute the length of the space-separated provider name string. */
39179237Sjb	while (prov != NULL) {
40179237Sjb		len += strlen(prov->dtpv_name) + 1;
41179237Sjb		prov = prov->dtpv_next;
42179237Sjb	}
43179237Sjb
44179237Sjb	if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)
45179237Sjb		error = ENOMEM;
46179237Sjb	else {
47179237Sjb		/* Start with an empty string. */
48179237Sjb		*p_name = '\0';
49179237Sjb
50179237Sjb		/* Point to the first provider again. */
51179237Sjb		prov = dtrace_provider;
52179237Sjb
53179237Sjb		/* Loop through the providers, appending the names. */
54179237Sjb		while (prov != NULL) {
55179237Sjb			if (prov != dtrace_provider)
56179237Sjb				(void) strlcat(p_name, " ", len);
57179237Sjb
58179237Sjb			(void) strlcat(p_name, prov->dtpv_name, len);
59179237Sjb
60179237Sjb			prov = prov->dtpv_next;
61179237Sjb		}
62179237Sjb	}
63179237Sjb
64179237Sjb	mutex_exit(&dtrace_lock);
65179237Sjb	mutex_exit(&dtrace_provider_lock);
66179237Sjb
67179237Sjb	if (p_name != NULL) {
68179237Sjb		error = sysctl_handle_string(oidp, p_name, len, req);
69179237Sjb
70179237Sjb		kmem_free(p_name, 0);
71179237Sjb	}
72179237Sjb
73179237Sjb	return (error);
74179237Sjb}
75179237Sjb
76298587SmarkjSYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters");
77298587Smarkj
78179237SjbSYSCTL_PROC(_debug_dtrace, OID_AUTO, providers, CTLTYPE_STRING | CTLFLAG_RD,
79262665Smarkj    0, 0, sysctl_dtrace_providers, "A", "available DTrace providers");
80179237Sjb
81262665SmarkjSYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace parameters");
82262665Smarkj
83298587SmarkjSYSCTL_INT(_kern_dtrace, OID_AUTO, err_verbose, CTLFLAG_RW,
84298587Smarkj    &dtrace_err_verbose, 0,
85298587Smarkj    "print DIF and DOF validation errors to the message buffer");
86298587Smarkj
87262665SmarkjSYSCTL_INT(_kern_dtrace, OID_AUTO, memstr_max, CTLFLAG_RW, &dtrace_memstr_max,
88256571Smarkj    0, "largest allowed argument to memstr(), 0 indicates no limit");
89262665Smarkj
90273377ShselaskySYSCTL_QUAD(_kern_dtrace, OID_AUTO, dof_maxsize, CTLFLAG_RW,
91262665Smarkj    &dtrace_dof_maxsize, 0, "largest allowed DOF table");
92262665Smarkj
93273377ShselaskySYSCTL_QUAD(_kern_dtrace, OID_AUTO, helper_actions_max, CTLFLAG_RW,
94262665Smarkj    &dtrace_helper_actions_max, 0, "maximum number of allowed helper actions");
95