diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-06-23 13:15:22 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2016-06-23 13:15:22 +0000 |
commit | 1d4142c67658599ccf36e930a28d8d51d75836ce (patch) | |
tree | fa210ba1f057067da5bd15128ffa4e62860bcfb8 /sys/kern | |
parent | 8d329fcc4764b68796f5bfc872399d05ced20443 (diff) |
It is annoying that the dmesg buffer can overflow and loose messages
undetected during debugging. To make clear what happens, count the
dropped bytes and write message buffer full to syslogd. This also
helps to have a reliable log system.
OK deraadt@ millert@ tedu@
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/subr_log.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 4c948e0fa83..dc0d90c1613 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.46 2016/06/08 11:11:47 bluhm Exp $ */ +/* $OpenBSD: subr_log.c,v 1.47 2016/06/23 13:15:21 bluhm Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -155,6 +155,7 @@ msgbuf_putchar(struct msgbuf *mbp, const char c) if (mbp->msg_bufr == mbp->msg_bufx) { if (++mbp->msg_bufr >= mbp->msg_bufs) mbp->msg_bufr = 0; + mbp->msg_bufd++; } splx(s); } @@ -201,6 +202,19 @@ logread(dev_t dev, struct uio *uio, int flag) } logsoftc.sc_state &= ~LOG_RDWAIT; + if (mbp->msg_bufd > 0) { + char buf[64]; + + l = snprintf(buf, sizeof(buf), + "<%d>klog: dropped %ld byte%s, message buffer full\n", + LOG_KERN|LOG_WARNING, mbp->msg_bufd, + mbp->msg_bufd == 1 ? "" : "s"); + error = uiomove(buf, ulmin(l, sizeof(buf) - 1), uio); + if (error) + goto out; + mbp->msg_bufd = 0; + } + while (uio->uio_resid > 0) { if (mbp->msg_bufx >= mbp->msg_bufr) l = mbp->msg_bufx - mbp->msg_bufr; |