PERFORCE change 73261 for review
John Baldwin
jhb at FreeBSD.org
Mon Mar 21 13:18:37 PST 2005
On Tuesday 15 March 2005 06:39 pm, Peter Wemm wrote:
> http://perforce.freebsd.org/chv.cgi?CH=73261
>
> Change 73261 by peter at 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 at FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/
"Power Users Use the Power to Serve" = http://www.FreeBSD.org
More information about the p4-projects
mailing list