summaryrefslogtreecommitdiffstats
path: root/sys/vm/vm_meter.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2004-10-11 22:04:16 +0000
committerpeter <peter@FreeBSD.org>2004-10-11 22:04:16 +0000
commit09964b7499a5ae22028b46962764b78d5e698410 (patch)
tree1829b174800facf808eb5d32c6e9b155f798a0f6 /sys/vm/vm_meter.c
parent89db558372e0f70245194eceebce5e8c90ee25dc (diff)
downloadFreeBSD-src-09964b7499a5ae22028b46962764b78d5e698410.zip
FreeBSD-src-09964b7499a5ae22028b46962764b78d5e698410.tar.gz
Put on my peril sensitive sunglasses and add a flags field to the internal
sysctl routines and state. Add some code to use it for signalling the need to downconvert a data structure to 32 bits on a 64 bit OS when requested by a 32 bit app. I tried to do this in a generic abi wrapper that intercepted the sysctl oid's, or looked up the format string etc, but it was a real can of worms that turned into a fragile mess before I even got it partially working. With this, we can now run 'sysctl -a' on a 32 bit sysctl binary and have it not abort. Things like netstat, ps, etc have a long way to go. This also fixes a bug in the kern.ps_strings and kern.usrstack hacks. These do matter very much because they are used by libc_r and other things.
Diffstat (limited to 'sys/vm/vm_meter.c')
-rw-r--r--sys/vm/vm_meter.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index 4c09acd..4c3d60b 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -85,8 +85,24 @@ SYSCTL_UINT(_vm, VM_V_PAGEOUT_FREE_MIN, v_pageout_free_min,
SYSCTL_UINT(_vm, OID_AUTO, v_free_severe,
CTLFLAG_RW, &cnt.v_free_severe, 0, "");
-SYSCTL_STRUCT(_vm, VM_LOADAVG, loadavg, CTLFLAG_RD,
- &averunnable, loadavg, "Machine loadaverage history");
+static int
+sysctl_vm_loadavg(SYSCTL_HANDLER_ARGS)
+{
+#ifdef SCTL_MASK32
+ u_int32_t la[4];
+
+ if (req->flags & SCTL_MASK32) {
+ la[0] = averunnable.ldavg[0];
+ la[1] = averunnable.ldavg[1];
+ la[2] = averunnable.ldavg[2];
+ la[3] = averunnable.fscale;
+ return SYSCTL_OUT(req, la, sizeof(la));
+ } else
+#endif
+ return SYSCTL_OUT(req, &averunnable, sizeof(averunnable));
+}
+SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD,
+ NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history");
static int
vmtotal(SYSCTL_HANDLER_ARGS)
OpenPOWER on IntegriCloud