summaryrefslogtreecommitdiffstats
path: root/sbin/dmesg
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-12-17 19:05:17 +0000
committerphk <phk@FreeBSD.org>2000-12-17 19:05:17 +0000
commitcb3b526426b2dad39a9c614005fc80e682658374 (patch)
tree061e0e8db18fea4ee99da4cffbfd9d860df71033 /sbin/dmesg
parentbb7f8457714084c3563d0a9e700c70c9eac929ea (diff)
downloadFreeBSD-src-cb3b526426b2dad39a9c614005fc80e682658374.zip
FreeBSD-src-cb3b526426b2dad39a9c614005fc80e682658374.tar.gz
Add a -a option to show the entire message buffer.
Diffstat (limited to 'sbin/dmesg')
-rw-r--r--sbin/dmesg/dmesg.86
-rw-r--r--sbin/dmesg/dmesg.c25
2 files changed, 26 insertions, 5 deletions
diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8
index 39f0e39..10c1d25 100644
--- a/sbin/dmesg/dmesg.8
+++ b/sbin/dmesg/dmesg.8
@@ -40,6 +40,7 @@
.Nd "display the system message buffer"
.Sh SYNOPSIS
.Nm
+.Op Fl a
.Op Fl M Ar core
.Op Fl N Ar system
.Sh DESCRIPTION
@@ -48,6 +49,11 @@ displays the contents of the system message buffer.
.Pp
The options are as follows:
.Bl -tag -width indent
+.It Fl a
+Show all data in the message buffer. This includes any syslog records
+and
+.Pa /dev/console
+output.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default
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;
}
OpenPOWER on IntegriCloud