.\" Copyright 1993 Rickard E. Faith (faith@cs.unc.edu)
.\" May be distributed under the GNU General Public License
-.TH DMESG 1
+.TH DMESG 1 "Jun 2011"
.SH NAME
dmesg \- print or control the kernel ring buffer
.SH SYNOPSIS
.B dmesg
.RB [ options ]
+.sp
+.B dmesg \-\-clear
+.sp
+.B dmesg \-\-read-clear
+.RB [ options ]
+.sp
+.B dmesg \-\-console-level
+.I level
.SH DESCRIPTION
.B dmesg
is used to examine or control the kernel ring buffer.
-The program helps users to print out their bootup messages. Instead of
-copying the messages by hand, the user need only:
-.RS
-dmesg > boot.messages
-.RE
-and mail the
-.I boot.messages
-file to whoever can debug their problem.
+The default action is to read all messages from kernel ring buffer.
+
.SH OPTIONS
+The --clear, --read-clear and --console-level options are mutually exclusive.
+
.IP "\fB\-C, \-\-clear\fP"
Clear the ring buffer.
.IP "\fB\-c, \-\-read-clear\fP"
int n;
int c;
int console_level = 0;
- int cmd = SYSLOG_ACTION_READ_ALL;
+ int cmd = -1;
int flags = 0;
static const struct option longopts[] = {
textdomain(PACKAGE);
while ((c = getopt_long(argc, argv, "Cchrn:s:V", longopts, NULL)) != -1) {
+
+ if (cmd != -1 && strchr("Ccn", c))
+ errx(EXIT_FAILURE, "%s %s",
+ "--{clear,read-clear,console-level}",
+ _("options are mutually exclusive"));
+
switch (c) {
case 'C':
cmd = SYSLOG_ACTION_CLEAR;
flags |= DMESG_FL_RAW;
break;
case 's':
- bufsize = strtol_or_err(optarg, _("failed to parse buffer size"));
+ bufsize = strtol_or_err(optarg,
+ _("failed to parse buffer size"));
if (bufsize < 4096)
bufsize = 4096;
break;
if (argc > 1)
usage(stderr);
+ if (cmd == -1)
+ cmd = SYSLOG_ACTION_READ_ALL; /* default */
+
switch (cmd) {
case SYSLOG_ACTION_READ_ALL:
case SYSLOG_ACTION_READ_CLEAR: