Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Mar 2005 14:30:05 -0500
From:      John Baldwin <jhb@FreeBSD.org>
To:        Peter Wemm <peter@FreeBSD.org>
Cc:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   Re: PERFORCE change 73261 for review
Message-ID:  <200503211430.05815.jhb@FreeBSD.org>
In-Reply-To: <200503152339.j2FNdwld011634@repoman.freebsd.org>
References:  <200503152339.j2FNdwld011634@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday 15 March 2005 06:39 pm, Peter Wemm wrote:
> http://perforce.freebsd.org/chv.cgi?CH=73261
>
> Change 73261 by peter@peter_daintree on 2005/03/15 23:39:35
>
> 	I'm ashamed, but this will do as an interim measure.
> 	I feel a req->flags flag coming on.

req->flags would suck.  You almost want to wrap sysctl() and add an exception 
list for freebsd32_sysctl() that does a copyin() and kernel_sysctl() and then 
copyout(), but that's still ugly. :(

> Affected files ...
>
> .. //depot/projects/hammer/sys/kern/kern_clock.c#23 edit
>
> Differences ...
>
> ==== //depot/projects/hammer/sys/kern/kern_clock.c#23 (text+ko) ====
>
> @@ -39,6 +39,7 @@
>
>  #include "opt_ntp.h"
>  #include "opt_watchdog.h"
> +#include "opt_compat.h"
>
>  #include <sys/param.h>
>  #include <sys/systm.h>
> @@ -79,8 +80,36 @@
>  /* Some of these don't belong here, but it's easiest to concentrate them.
> */ long cp_time[CPUSTATES];
>
> -SYSCTL_OPAQUE(_kern, OID_AUTO, cp_time, CTLFLAG_RD, &cp_time,
> sizeof(cp_time), -    "LU", "CPU time statistics");
> +#ifdef COMPAT_IA32
> +extern struct sysentvec ia32_freebsd_sysvec;
> +#endif
> +
> +static int
> +sysctl_kern_cp_time(SYSCTL_HANDLER_ARGS)
> +{
> +	int error;
> +#ifdef COMPAT_IA32
> +	int i;
> +	unsigned int cp_time32[CPUSTATES];
> +
> +	if (req->td->td_proc->p_sysent == &ia32_freebsd_sysvec) {
> +		if (!req->oldptr)
> +			return SYSCTL_OUT(req, 0, sizeof(cp_time32));
> +		for (i = 0; i < CPUSTATES; i++)
> +			cp_time32[i] = (unsigned int)cp_time[i];
> +		error = SYSCTL_OUT(req, cp_time32, sizeof(cp_time32));
> +	} else
> +#endif
> +	{
> +		if (!req->oldptr)
> +			return SYSCTL_OUT(req, 0, sizeof(cp_time));
> +		error = SYSCTL_OUT(req, cp_time, sizeof(cp_time));
> +	}
> +	return error;
> +}
> +
> +SYSCTL_PROC(_kern, OID_AUTO, cp_time, CTLTYPE_LONG|CTLFLAG_RD,
> +    0,0, sysctl_kern_cp_time, "LU", "CPU time statistics");
>
>  #ifdef SW_WATCHDOG
>  #include <sys/watchdog.h>

-- 
John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve"  =  http://www.FreeBSD.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503211430.05815.jhb>