summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2011-07-01 14:56:22 +0200
committerKarel Zak2011-07-01 14:56:22 +0200
commit0506537a1044f68981e7f153c019a6d7b8748b08 (patch)
tree53d59e67f45ac9f3a22eced4de869a15127e8cc5 /sys-utils
parentdmesg: add --clear (SYSLOG_ACTION_CLEAR) (diff)
downloadkernel-qcow2-util-linux-0506537a1044f68981e7f153c019a6d7b8748b08.tar.gz
kernel-qcow2-util-linux-0506537a1044f68981e7f153c019a6d7b8748b08.tar.xz
kernel-qcow2-util-linux-0506537a1044f68981e7f153c019a6d7b8748b08.zip
dmesg: cleanup options and man page
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/dmesg.122
-rw-r--r--sys-utils/dmesg.c14
2 files changed, 25 insertions, 11 deletions
diff --git a/sys-utils/dmesg.1 b/sys-utils/dmesg.1
index 64234d0c0..85f4dc04d 100644
--- a/sys-utils/dmesg.1
+++ b/sys-utils/dmesg.1
@@ -1,24 +1,28 @@
.\" 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"
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index a53f49140..50b073f3f 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -133,7 +133,7 @@ int main(int argc, char *argv[])
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[] = {
@@ -152,6 +152,12 @@ int main(int argc, char *argv[])
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;
@@ -168,7 +174,8 @@ int main(int argc, char *argv[])
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;
@@ -190,6 +197,9 @@ int main(int argc, char *argv[])
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: