diff options
author | phk <phk@FreeBSD.org> | 2000-12-17 19:05:17 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-12-17 19:05:17 +0000 |
commit | cb3b526426b2dad39a9c614005fc80e682658374 (patch) | |
tree | 061e0e8db18fea4ee99da4cffbfd9d860df71033 /sbin/dmesg/dmesg.c | |
parent | bb7f8457714084c3563d0a9e700c70c9eac929ea (diff) | |
download | FreeBSD-src-cb3b526426b2dad39a9c614005fc80e682658374.zip FreeBSD-src-cb3b526426b2dad39a9c614005fc80e682658374.tar.gz |
Add a -a option to show the entire message buffer.
Diffstat (limited to 'sbin/dmesg/dmesg.c')
-rw-r--r-- | sbin/dmesg/dmesg.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c index 6071680..541e9df 100644 --- a/sbin/dmesg/dmesg.c +++ b/sbin/dmesg/dmesg.c @@ -55,6 +55,7 @@ static const char rcsid[] = #include <stdlib.h> #include <unistd.h> #include <vis.h> +#include <sys/syslog.h> struct nlist nl[] = { #define X_MSGBUF 0 @@ -72,17 +73,22 @@ main(argc, argv) int argc; char *argv[]; { - register int ch, newl, skip; - register char *p, *ep; + int ch, newl, skip; + char *p, *ep; struct msgbuf *bufp, cur; char *bp, *memf, *nlistf; kvm_t *kd; char buf[5]; + int all = 0; + int pri; (void) setlocale(LC_CTYPE, ""); memf = nlistf = NULL; - while ((ch = getopt(argc, argv, "M:N:")) != -1) + while ((ch = getopt(argc, argv, "aM:N:")) != -1) switch(ch) { + case 'a': + all++; + break; case 'M': memf = optarg; break; @@ -140,11 +146,20 @@ main(argc, argv) ch = *p; /* Skip "\n<.*>" syslog sequences. */ if (skip) { - if (ch == '>') - newl = skip = 0; + if (ch == '\n') { + skip = 0; + newl = 1; + } if (ch == '>') { + if (LOG_FAC(pri) == LOG_KERN || all) + newl = skip = 0; + } else if (ch >= '0' && ch <= '9') { + pri *= 10; + pri += ch - '0'; + } continue; } if (newl && ch == '<') { + pri = 0; skip = 1; continue; } |