diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-04-14 21:58:51 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2005-04-14 21:58:51 +0000 |
commit | 994cb8839e7244de556e8fe53247392b0ed6cdfc (patch) | |
tree | 170c3a6f411478d8f521873652434215466052a5 /sys | |
parent | b27a36dbfa5518ff1240fbc7739730e82464401d (diff) |
Try to start log message buffer on a new line. Helps install scripts avoid
detecting phantom devices when scanning dmesg output.
Suggested by miod@, ok deraadt@.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_log.c | 33 | ||||
-rw-r--r-- | sys/kern/subr_prf.c | 20 | ||||
-rw-r--r-- | sys/sys/msgbuf.h | 3 |
3 files changed, 33 insertions, 23 deletions
diff --git a/sys/kern/subr_log.c b/sys/kern/subr_log.c index 98eb65c87ca..dbcc9889420 100644 --- a/sys/kern/subr_log.c +++ b/sys/kern/subr_log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_log.c,v 1.11 2003/09/23 16:51:12 millert Exp $ */ +/* $OpenBSD: subr_log.c,v 1.12 2005/04/14 21:58:50 krw Exp $ */ /* $NetBSD: subr_log.c,v 1.11 1996/03/30 22:24:44 christos Exp $ */ /* @@ -77,7 +77,7 @@ initmsgbuf(buf, bufsize) caddr_t buf; size_t bufsize; { - register struct msgbuf *mbp; + struct msgbuf *mbp; long new_bufs; /* Sanity-check the given size. */ @@ -100,11 +100,34 @@ initmsgbuf(buf, bufsize) mbp->msg_magic = MSG_MAGIC; mbp->msg_bufs = new_bufs; } + + /* Always start new buffer data on a new line. */ + if (mbp->msg_bufx > 0 && mbp->msg_bufc[mbp->msg_bufx - 1] != '\n') + msgbuf_putchar('\n'); /* mark it as ready for use. */ msgbufmapped = msgbufenabled = 1; } +void msgbuf_putchar(const char c) +{ + struct msgbuf *mbp = msgbufp; + + if (mbp->msg_magic != MSG_MAGIC) + /* Nothing we can do */ + return; + + mbp->msg_bufc[mbp->msg_bufx++] = c; + mbp->msg_bufl = min(mbp->msg_bufl+1, mbp->msg_bufs); + if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs) + mbp->msg_bufx = 0; + /* If the buffer is full, keep the most recent data. */ + if (mbp->msg_bufr == mbp->msg_bufx) { + if (++mbp->msg_bufr >= mbp->msg_bufs) + mbp->msg_bufr = 0; + } +} + /*ARGSUSED*/ int logopen(dev, flags, mode, p) @@ -138,9 +161,9 @@ logread(dev, uio, flag) struct uio *uio; int flag; { - register struct msgbuf *mbp = msgbufp; - register long l; - register int s; + struct msgbuf *mbp = msgbufp; + long l; + int s; int error = 0; s = splhigh(); diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index e4d04aa0bc7..8c5edfab33e 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_prf.c,v 1.60 2004/07/20 20:19:52 art Exp $ */ +/* $OpenBSD: subr_prf.c,v 1.61 2005/04/14 21:58:50 krw Exp $ */ /* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */ /*- @@ -335,7 +335,6 @@ void kputchar(int c, int flags, struct tty *tp) { extern int msgbufmapped; - struct msgbuf *mbp; if (panicstr) constty = NULL; @@ -347,21 +346,8 @@ kputchar(int c, int flags, struct tty *tp) (flags & TOCONS) && tp == constty) constty = NULL; if ((flags & TOLOG) && - c != '\0' && c != '\r' && c != 0177 && msgbufmapped) { - mbp = msgbufp; - if (mbp->msg_magic != MSG_MAGIC) { - /* Nothing we can do */ - } - mbp->msg_bufc[mbp->msg_bufx++] = c; - mbp->msg_bufl = min(mbp->msg_bufl+1, mbp->msg_bufs); - if (mbp->msg_bufx < 0 || mbp->msg_bufx >= mbp->msg_bufs) - mbp->msg_bufx = 0; - /* If the buffer is full, keep the most recent data. */ - if (mbp->msg_bufr == mbp->msg_bufx) { - if (++mbp->msg_bufr >= mbp->msg_bufs) - mbp->msg_bufr = 0; - } - } + c != '\0' && c != '\r' && c != 0177 && msgbufmapped) + msgbuf_putchar(c); if ((flags & TOCONS) && constty == NULL && c != '\0') (*v_putc)(c); #ifdef DDB diff --git a/sys/sys/msgbuf.h b/sys/sys/msgbuf.h index 347e7480234..bce761e3036 100644 --- a/sys/sys/msgbuf.h +++ b/sys/sys/msgbuf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: msgbuf.h,v 1.7 2003/06/02 23:28:21 millert Exp $ */ +/* $OpenBSD: msgbuf.h,v 1.8 2005/04/14 21:58:50 krw Exp $ */ /* $NetBSD: msgbuf.h,v 1.8 1995/03/26 20:24:27 jtc Exp $ */ /* @@ -45,4 +45,5 @@ struct msgbuf { extern struct msgbuf *msgbufp; void initmsgbuf(caddr_t buf, size_t bufsize); +void msgbuf_putchar(const char c); #endif |