From owner-p4-projects@FreeBSD.ORG Thu Apr 20 00:57:36 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 22EFB16A403; Thu, 20 Apr 2006 00:57:36 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD35716A401 for ; Thu, 20 Apr 2006 00:57:35 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id A913A43D46 for ; Thu, 20 Apr 2006 00:57:35 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.1/8.13.1) with ESMTP id k3K0vZXn077769 for ; Thu, 20 Apr 2006 00:57:35 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.1/8.13.1/Submit) id k3K0vZsJ077763 for perforce@freebsd.org; Thu, 20 Apr 2006 00:57:35 GMT (envelope-from jb@freebsd.org) Date: Thu, 20 Apr 2006 00:57:35 GMT Message-Id: <200604200057.k3K0vZsJ077763@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 95640 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Apr 2006 00:57:36 -0000 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); }