]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/cddl/dev/dtrace/dtrace_sysctl.c
dtrace: add missing CLTFLAG_MPSAFE annotations
[FreeBSD/FreeBSD.git] / sys / cddl / dev / dtrace / dtrace_sysctl.c
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  * $FreeBSD$
22  *
23  */
24
25 /* Report registered DTrace providers. */
26 static int
27 sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS)
28 {
29         char    *p_name = NULL;
30         dtrace_provider_t
31                 *prov   = dtrace_provider;
32         int     error   = 0;
33         size_t  len     = 0;
34
35         mutex_enter(&dtrace_provider_lock);
36         mutex_enter(&dtrace_lock);
37
38         /* Compute the length of the space-separated provider name string. */
39         while (prov != NULL) {
40                 len += strlen(prov->dtpv_name) + 1;
41                 prov = prov->dtpv_next;
42         }
43
44         if ((p_name = kmem_alloc(len, KM_SLEEP)) == NULL)
45                 error = ENOMEM;
46         else {
47                 /* Start with an empty string. */
48                 *p_name = '\0';
49
50                 /* Point to the first provider again. */
51                 prov = dtrace_provider;
52
53                 /* Loop through the providers, appending the names. */
54                 while (prov != NULL) {
55                         if (prov != dtrace_provider)
56                                 (void) strlcat(p_name, " ", len);
57
58                         (void) strlcat(p_name, prov->dtpv_name, len);
59
60                         prov = prov->dtpv_next;
61                 }
62         }
63
64         mutex_exit(&dtrace_lock);
65         mutex_exit(&dtrace_provider_lock);
66
67         if (p_name != NULL) {
68                 error = sysctl_handle_string(oidp, p_name, len, req);
69
70                 kmem_free(p_name, 0);
71         }
72
73         return (error);
74 }
75
76 SYSCTL_NODE(_debug, OID_AUTO, dtrace, CTLFLAG_RD, 0, "DTrace debug parameters");
77
78 SYSCTL_PROC(_debug_dtrace, OID_AUTO, providers,
79     CTLTYPE_STRING | CTLFLAG_MPSAFE | CTLFLAG_RD, 0, 0, sysctl_dtrace_providers,
80     "A", "available DTrace providers");
81
82 SYSCTL_NODE(_kern, OID_AUTO, dtrace, CTLFLAG_RD, 0, "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(_security_bsd, OID_AUTO, allow_destructive_dtrace, CTLFLAG_RDTUN,
98     &dtrace_allow_destructive, 1, "Allow destructive mode DTrace scripts");