diff options
author | peter <peter@FreeBSD.org> | 2004-10-11 22:04:16 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2004-10-11 22:04:16 +0000 |
commit | 09964b7499a5ae22028b46962764b78d5e698410 (patch) | |
tree | 1829b174800facf808eb5d32c6e9b155f798a0f6 /sys/kern/kern_tc.c | |
parent | 89db558372e0f70245194eceebce5e8c90ee25dc (diff) | |
download | FreeBSD-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/kern/kern_tc.c')
-rw-r--r-- | sys/kern/kern_tc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sys/kern/kern_tc.c b/sys/kern/kern_tc.c index 984d237..4567dde 100644 --- a/sys/kern/kern_tc.c +++ b/sys/kern/kern_tc.c @@ -92,8 +92,9 @@ time_t time_uptime = 0; static struct bintime boottimebin; struct timeval boottime; -SYSCTL_STRUCT(_kern, KERN_BOOTTIME, boottime, CTLFLAG_RD, - &boottime, timeval, "System boottime"); +static int sysctl_kern_boottime(SYSCTL_HANDLER_ARGS); +SYSCTL_PROC(_kern, KERN_BOOTTIME, boottime, CTLTYPE_STRUCT|CTLFLAG_RD, + NULL, 0, sysctl_kern_boottime, "S,timeval", "System boottime"); SYSCTL_NODE(_kern, OID_AUTO, timecounter, CTLFLAG_RW, 0, ""); @@ -116,6 +117,20 @@ TC_STATS(nsetclock); static void tc_windup(void); +static int +sysctl_kern_boottime(SYSCTL_HANDLER_ARGS) +{ +#ifdef SCTL_MASK32 + int tv[2]; + + if (req->flags & SCTL_MASK32) { + tv[0] = boottime.tv_sec; + tv[1] = boottime.tv_usec; + return SYSCTL_OUT(req, tv, sizeof(tv)); + } else +#endif + return SYSCTL_OUT(req, &boottime, sizeof(boottime)); +} /* * Return the difference between the timehands' counter value now and what * was when we copied it to the timehands' offset_count. |