Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src kern.boottime was changed from a struct timeval to a struct ...
details: https://anonhg.NetBSD.org/src/rev/71e2d28ce758
branches: trunk
changeset: 445487:71e2d28ce758
user: kre <kre%NetBSD.org@localhost>
date: Tue Oct 30 19:41:21 2018 +0000
description:
kern.boottime was changed from a struct timeval to a struct timespec
in January 2009 (the Christos' time merge, when time_t went to 64 bits).
sysctl needs to catch up. (So do other progs, which will happen, eventually,
but most of them are unaffected in any practical way.)
If you are running a system (NetBSD 6 or later) without this change, try
sysctl -nn kern.boottime
and marvel at the result (in theory, seconds.microseconds) most
probably being something like:
jinx$ sysctl -nn kern.boottime
1540801874.999995564
(There is a 1 in 1000 chance your system will have booted
in the interval [0 , 999999] nanoseconds after some second,
in which case this will not be observed. You should get
(almost) the same value after this change - just now it is as
it should be (there should now always be 9 digits after the '.').
On the other hand, if you're on a big-endian 64 bit host (running
64 bit sysctl) you would have always seen 0 for the microseconds field.
That should be fixed by this.
In sysctl(7) also document what we mean by "the time the system booted".
XXX Pullup -8
XXX Pullup -7
XXX Pullup -6 (oops, missed that one...)
diffstat:
sbin/sysctl/sysctl.c | 22 +++++++++++-----------
share/man/man7/sysctl.7 | 10 ++++++----
2 files changed, 17 insertions(+), 15 deletions(-)
diffs (100 lines):
diff -r d46fe552b6e6 -r 71e2d28ce758 sbin/sysctl/sysctl.c
--- a/sbin/sysctl/sysctl.c Tue Oct 30 19:40:35 2018 +0000
+++ b/sbin/sysctl/sysctl.c Tue Oct 30 19:41:21 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sysctl.c,v 1.160 2018/02/04 09:03:23 mrg Exp $ */
+/* $NetBSD: sysctl.c,v 1.161 2018/10/30 19:41:21 kre Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
#if 0
static char sccsid[] = "@(#)sysctl.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: sysctl.c,v 1.160 2018/02/04 09:03:23 mrg Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.161 2018/10/30 19:41:21 kre Exp $");
#endif
#endif /* not lint */
@@ -2189,32 +2189,32 @@
static void
kern_boottime(HANDLER_ARGS)
{
- struct timeval timeval;
+ struct timespec timespec;
time_t boottime;
size_t sz;
int rc;
- sz = sizeof(timeval);
- rc = prog_sysctl(name, namelen, &timeval, &sz, NULL, 0);
+ sz = sizeof(timespec);
+ rc = prog_sysctl(name, namelen, ×pec, &sz, NULL, 0);
if (rc == -1) {
sysctlerror(1);
return;
}
- if (sz != sizeof(timeval))
+ if (sz != sizeof(timespec))
errx(EXIT_FAILURE, "%s: !returned size wrong!", sname);
- boottime = timeval.tv_sec;
+ boottime = timespec.tv_sec;
if (xflag || rflag)
- display_struct(pnode, sname, &timeval, sz,
+ display_struct(pnode, sname, ×pec, sz,
DISPLAY_VALUE);
else if (!nflag)
/* ctime() provides the \n */
printf("%s%s%s", sname, eq, ctime(&boottime));
else if (nflag == 1)
- printf("%ld\n", (long)boottime);
+ printf("%lld\n", (long long)boottime);
else
- printf("%ld.%06ld\n", (long)timeval.tv_sec,
- (long)timeval.tv_usec);
+ printf("%lld.%9.9ld\n", (long long)timespec.tv_sec,
+ timespec.tv_nsec);
}
/*ARGSUSED*/
diff -r d46fe552b6e6 -r 71e2d28ce758 share/man/man7/sysctl.7
--- a/share/man/man7/sysctl.7 Tue Oct 30 19:40:35 2018 +0000
+++ b/share/man/man7/sysctl.7 Tue Oct 30 19:41:21 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sysctl.7,v 1.133 2018/10/06 13:53:58 wiz Exp $
+.\" $NetBSD: sysctl.7,v 1.134 2018/10/30 19:41:21 kre Exp $
.\"
.\" Copyright (c) 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\"
-.Dd October 5, 2018
+.Dd October 30, 2018
.Dt SYSCTL 7
.Os
.Sh NAME
@@ -278,7 +278,7 @@
.It kern.arandom integer no
.It kern.argmax integer no
.It kern.boothowto integer no
-.It kern.boottime struct timeval no
+.It kern.boottime struct timespec no
.It kern.buildinfo string no
.\".It kern.bufq node not applicable
.It kern.ccpu integer no
@@ -396,9 +396,11 @@
for the meanings of the flags.
.It Li kern.boottime ( Dv KERN_BOOTTIME )
A
-.Vt struct timeval
+.Vt struct timespec
structure is returned.
This structure contains the time that the system was booted.
+That time is defined (for this purpose) to be the time at
+which the kernel first started accumulating clock ticks.
.It Li kern.bufq
This variable contains information on the
.Xr bufq 9
Home |
Main Index |
Thread Index |
Old Index