Home | History | Annotate | Download | only in dmesg
History log of /src/sbin/dmesg/dmesg.c
RevisionDateAuthorComments
 1.51  06-Aug-2022  rin Assert postts only if we really obtained a timestamp.
 1.50  06-Aug-2022  rin Do not declare unused tstamp for SMALL. NFC.
 1.49  06-Aug-2022  rin Get back to the statically-allocated tbuf.

If a string is longer than tbuf, it cannot be a timestamp.
Therefore, no need for buffering anymore in this case.
 1.48  06-Aug-2022  rin Oops, fix thinko in the previous.
 1.47  06-Aug-2022  rin Do not discard \[.*\] which is not identified as a timestamp.
 1.46  06-Aug-2022  rin KNF. Do not unnecessarily define ADDC() for SMALL. No binary changes.
 1.45  01-Jan-2020  kre Make recent change build for SMALL builds as well as normal ones.
 1.44  31-Dec-2019  tsutsui Fix dmesg(8) to preserve leading whitespaces of kernel messages.

Closes PR/54729.
 1.43  04-Jun-2019  kre branches: 1.43.2;

Delete a redundant (useless) assignment. NFCI.
 1.42  04-Jun-2019  kre PR toolchain/54269

Make a SMALL dmesg even smaller.

When compiled -DSMALL, dmesg does nothing at all with the kernel
timestamps (it processes no options to be told what would be the
user's desire) so make it truly do (almost) nothing, rather than
some botched partial processing of them.

The "almost" is that a SMALL dmesg will now ignore spaces at the
beginning of each new message line ... those are (vanishingly)
unlikely to occur, as the kernel puts the timestamp (which starts
with '[' there) - fixing this would have meant even more #ifdef's
as the code that ignores that leading space is the only remaining
thing that (in a SMALL) dmesg looks at the value of the "tstamp"
variable, and if we don't keep some use of it, gcc complains...

These changes affect only SMALL dmesg (as installed on boot
floppies, etc) and have no intended effect on the version that's
installed on a normal (full size) running system.
 1.41  30-Oct-2018  kre Correct the 6 second offset issue between the time reported by
dmesg -T and the actual time a message was produced, noted on
current-users by Geoff Wing (Oct 27, 2018).

The size of the offset would depend upon architecture, and processor,
but was the delay from starting the clocks to initialising the time
of day (after mounting root, in case that is needed).

Change the kernel to set boottime to be the time at which the
clocks were started, rather than the time at which it is init'd
(by subtracting the interval between).

Correct dmesg to properly compute the ToD based upon the
boottime (which is a timespec, not a timeval, and has been
since Jan 2009) and the time logged in the message.

Note that this can (rarely) be 1 second earlier than date reports.
This occurs when the time when the message was logged was actually
in the next second, but the timecounters have not yet processed
the tick, and so the time of the last tick, near the end of the
previous second, is reported instead. Since times are always
truncated, rather than rounded, it is occasionally possible to
observe that disparity (if you try hard enough).

IOW: sys/kern/subr_prf.c:addtstamp() uses getnanouptime() rather
than nanouptime().

Note in dmesg(8) that -T conversions are gibberish other than
when the message comes from current the running kernel. (It
could be fixed when -M is used, for messages generated by the
kernel whose corpse is being observed. But hasn't been...)
 1.40  20-Sep-2018  kre Whitespace. NFC.
 1.39  20-Sep-2018  kre Use the locale's numeric radix character ("decimal point") more generally
(in !SMALL versions of dmesg).
 1.38  20-Sep-2018  kre Remove #if 0'd code that somehow got mangled in the (somewhat messy)
commit process and ended up being a syntax error...
 1.37  19-Sep-2018  christos changes from kre@
- pass intmax to fmtydhmsf instead of time_t to avoid extra conversions.
- make -TTT mean "always keep 3 decimal digits of duration precision" (ie:
always print ms) (including trailing 0's, even .000 if it happens)
- make -T (all forms) be subject to the locale (obey the radix character)
- don't print ymd, since that would require calendar calculations to get
right.
 1.36  19-Sep-2018  kre Allow a third use of -T to force .NNN (always three digits) in -TT
(ISO8601 durations) format for timestamps - that is,not dropping trailing 0's.
 1.35  19-Sep-2018  kre In -TT mode (ISO8601 duration timestamps) print milliseconds as
decimal fractions of a second (as they should be) rather than integer
milliseconds (ie nnn.1means nnn seconds and 1/10 of a second, not
nnn seconds, and 1 millisecond). While here convert some inappropriate
time_t usage to intmax_t which works better (int, or long, would probably
work just as well).
 1.34  19-Sep-2018  christos add -TT printing ISO 8601 duration
 1.33  14-Apr-2018  kre branches: 1.33.2;

Make timestamp reading code adapt to whatever precision (up to
nanoseconds, 9 digits) the kernel happens to send in the timestamps
in log messages.

Output (numeric) timestamps (when produced) are unchanged and always
in microseconds (for now).
 1.32  11-Apr-2018  wiz Update usage.
 1.31  10-Apr-2018  christos match the linux dmesg flags.
 1.30  02-Apr-2018  christos eat NUL's first so that the state machine is not altered by them.
 1.29  01-Apr-2018  christos handle log being before timestamp...
 1.28  01-Apr-2018  christos Handle new timestamp sequences.
 1.27  29-Aug-2011  joerg branches: 1.27.40;
Use __dead
 1.26  20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.25  16-Oct-2006  christos branches: 1.25.18; 1.25.22;
c99 initializer
 1.24  05-Sep-2005  dsl Make is worthwhile haveing #ifdef SMALL by making the Makefile set it when
SMALLPROG is defined (eg by src/distrib/commonMakefile.crunch).
Shrink SMALL version even more.
 1.23  20-Jan-2005  xtraeme Remove main() prototype; WARNS=2
 1.22  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.21  05-Jun-2002  augustss Make it possible to see \ in dmesg.
 1.20  20-Jun-2000  simonb branches: 1.20.2;
If "SMALL" is defined don't include kvm support, primarily for install
media.
 1.19  16-Jun-2000  simonb Don't check namelist when choosing to use the sysctl interface.
 1.18  16-Jun-2000  simonb ANSIfy.
 1.17  16-Jun-2000  simonb Use new KERN_MSGBUF sysctl if running on a live kernel, and remove
setgid kmem bit from executable.
 1.16  05-Jul-1998  mrg branches: 1.16.8;
discard privs as soon as possible.
 1.15  20-Sep-1997  enami Cosmetic change;

- indent continuation line by four space.
- put an empty line at the beginning of function which has no local variable.
 1.14  20-Sep-1997  enami Fix revived bug, described in PR#3285. But use a bit simple way;
Use loop count instead of hackery pointer play.
 1.13  20-Sep-1997  enami Don't include <sys/cdefs.h> twice in same file.
 1.12  19-Sep-1997  leo Commit userland part of pr-1891.
 1.11  14-Sep-1997  lukem - cleanup for WARNS=1
- cleanup .Nm usage
 1.10  03-May-1997  mjacob We need a hint of *what* address is bad on the kvm_read. Also,
there are two reads- one for the msgbuf pointer, and then that
for what it points to.
 1.9  06-Mar-1997  thorpej Don't get stuck in an infinite loop if the msgbuf index is 0 or 1, from
enami tsugutomo <enami@ba2.so-net.or.jp>, PR #3285.
 1.8  18-Mar-1995  cgd branches: 1.8.6;
convert to new RCS Id conventions; reduce my headache
 1.7  05-Dec-1994  cgd more cleanups from Jim Jegers, passed over by me.
 1.6  11-May-1994  cgd clean up import
 1.5  13-Oct-1993  jtc #include <unistd.h>, so getopt(), optarg, opterr, optind, and optopt
declarations can be removed from <stdlib.h>.
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2  22-Mar-1993  cgd added rcs ids to all files
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  11-May-1994  cgd oops
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.8.6.1  06-Mar-1997  thorpej Pull up from trunk:

Don't get stuck in an infinite loop if the msgbuf index is 0 or 1, from
enami tsugutomo <enami@ba2.so-net.or.jp>, PR #3285.
 1.16.8.1  22-Jun-2000  minoura Sync w/ netbsd-1-5-base.
 1.20.2.2  20-Jun-2000  simonb If "SMALL" is defined don't include kvm support, primarily for install
media.
 1.20.2.1  20-Jun-2000  simonb file dmesg.c was added on branch netbsd-1-5 on 2000-06-20 01:49:21 +0000
 1.25.22.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.25.18.1  28-Sep-2008  mjf Sync with HEAD.
 1.27.40.4  26-Nov-2018  pgoyette Sync with HEAD, resolve a couple of conflicts
 1.27.40.3  30-Sep-2018  pgoyette Ssync with HEAD
 1.27.40.2  16-Apr-2018  pgoyette Sync with HEAD, resolve some conflicts
 1.27.40.1  07-Apr-2018  pgoyette Sync with HEAD. 77 conflicts resolved - all of them $NetBSD$
 1.33.2.2  08-Apr-2020  martin Merge changes from current as of 20200406
 1.33.2.1  10-Jun-2019  christos Sync with HEAD
 1.43.2.1  05-Jan-2020  martin Pull up following revision(s) (requested by tsutsui in ticket #601):

sbin/dmesg/dmesg.c: revision 1.44
sbin/dmesg/dmesg.c: revision 1.45

Fix dmesg(8) to preserve leading whitespaces of kernel messages.
Closes PR/54729.

Make recent change build for SMALL builds as well as normal ones.

RSS XML Feed