Date: Thu, 20 Apr 2006 00:57:35 GMT From: John Birrell <jb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 95640 for review Message-ID: <200604200057.k3K0vZsJ077763@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95640 Change 95640 by jb@jb_freebsd2 on 2006/04/20 00:56:56 Now that the provider list is being populated, use it to feed the debug.dtrace.providers sysctl value. Affected files ... .. //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_sysctl.c#2 edit Differences ... ==== //depot/projects/dtrace/src/sys/cddl/dev/dtrace/dtrace_sysctl.c#2 (text+ko) ==== @@ -32,11 +32,49 @@ static int sysctl_dtrace_providers(SYSCTL_HANDLER_ARGS) { - char newname[32]; - strlcpy(newname, "someone", sizeof(newname)); - int error; + char *p_name = NULL; + dtrace_provider_t + *prov = dtrace_provider; + int error = 0; + size_t len = 0; + + mutex_enter(&dtrace_provider_lock); + mutex_enter(&dtrace_lock); + + /* Compute the length of the space-separated provider name string. */ + while (prov != NULL) { + len += strlen(prov->dtpv_name) + 1; + prov = prov->dtpv_next; + } + + if ((p_name = malloc(len, M_DTRACE, M_NOWAIT)) == NULL) + error = ENOMEM; + else { + /* Start with an empty string. */ + *p_name = '\0'; + + /* Point to the first provider again. */ + prov = dtrace_provider; + + /* Loop through the providers, appending the names. */ + while (prov != NULL) { + if (prov != dtrace_provider) + (void) strlcat(p_name, " ", len); + + (void) strlcat(p_name, prov->dtpv_name, len); + + prov = prov->dtpv_next; + } + } + + mutex_exit(&dtrace_lock); + mutex_exit(&dtrace_provider_lock); + + if (p_name != NULL) { + error = sysctl_handle_string(oidp, p_name, len, req); - error = sysctl_handle_string(oidp, &newname[0], sizeof(newname), req); + free(p_name, M_DTRACE); + } return (error); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200604200057.k3K0vZsJ077763>