summaryrefslogtreecommitdiffstats
path: root/sbin/dmesg
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
committersjg <sjg@FreeBSD.org>2013-09-05 20:18:59 +0000
commit62bb1062226d3ce6a2350808256a25508978352d (patch)
tree22b131dceb13c3df96da594fbaadb693504797c7 /sbin/dmesg
parent72ab90509b3a51ab361bf710338f2ef44a4e360d (diff)
parent04932445481c2cb89ff69a83b961bdef3d64757e (diff)
downloadFreeBSD-src-62bb1062226d3ce6a2350808256a25508978352d.zip
FreeBSD-src-62bb1062226d3ce6a2350808256a25508978352d.tar.gz
Merge from head
Diffstat (limited to 'sbin/dmesg')
-rw-r--r--sbin/dmesg/dmesg.86
-rw-r--r--sbin/dmesg/dmesg.c19
2 files changed, 18 insertions, 7 deletions
diff --git a/sbin/dmesg/dmesg.8 b/sbin/dmesg/dmesg.8
index 9d05e6c..35446fb 100644
--- a/sbin/dmesg/dmesg.8
+++ b/sbin/dmesg/dmesg.8
@@ -28,7 +28,7 @@
.\" @(#)dmesg.8 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
-.Dd June 5, 1993
+.Dd May 9, 2013
.Dt DMESG 8
.Os
.Sh NAME
@@ -36,7 +36,7 @@
.Nd "display the system message buffer"
.Sh SYNOPSIS
.Nm
-.Op Fl a
+.Op Fl ac
.Op Fl M Ar core Op Fl N Ar system
.Sh DESCRIPTION
The
@@ -59,6 +59,8 @@ Show all data in the message buffer.
This includes any syslog records and
.Pa /dev/console
output.
+.It Fl c
+Clear the kernel buffer after printing.
.It Fl M
Extract values associated with the name list from the specified core.
.It Fl N
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c
index 002732c..f0fcb81 100644
--- a/sbin/dmesg/dmesg.c
+++ b/sbin/dmesg/dmesg.c
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <locale.h>
#include <nlist.h>
#include <stdio.h>
+#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -79,15 +80,20 @@ main(int argc, char *argv[])
kvm_t *kd;
size_t buflen, bufpos;
long pri;
- int all, ch;
+ int ch, clear;
+ bool all;
- all = 0;
+ all = false;
+ clear = false;
(void) setlocale(LC_CTYPE, "");
memf = nlistf = NULL;
- while ((ch = getopt(argc, argv, "aM:N:")) != -1)
+ while ((ch = getopt(argc, argv, "acM:N:")) != -1)
switch(ch) {
case 'a':
- all++;
+ all = true;
+ break;
+ case 'c':
+ clear = true;
break;
case 'M':
memf = optarg;
@@ -114,6 +120,9 @@ main(int argc, char *argv[])
errx(1, "malloc failed");
if (sysctlbyname("kern.msgbuf", bp, &buflen, NULL, 0) == -1)
err(1, "sysctl kern.msgbuf");
+ if (clear)
+ if (sysctlbyname("kern.msgbuf_clear", NULL, NULL, &clear, sizeof(int)))
+ err(1, "sysctl kern.msgbuf_clear");
} else {
/* Read in kernel message buffer and do sanity checks. */
kd = kvm_open(nlistf, memf, NULL, O_RDONLY, "dmesg");
@@ -196,6 +205,6 @@ main(int argc, char *argv[])
void
usage(void)
{
- (void)fprintf(stderr, "usage: dmesg [-a] [-M core [-N system]]\n");
+ fprintf(stderr, "usage: dmesg [-ac] [-M core [-N system]]\n");
exit(1);
}
OpenPOWER on IntegriCloud