]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: cleanup options and man page
authorKarel Zak <kzak@redhat.com>
Fri, 1 Jul 2011 12:56:22 +0000 (14:56 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Jul 2011 12:56:22 +0000 (14:56 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.1
sys-utils/dmesg.c

index 64234d0c005aff6df2e35ed52790ce41e08397ad..85f4dc04df3d763f5410b9d7fc35a7e8d30fa6b8 100644 (file)
@@ -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"
index a53f491401e7522539aa2ee8b5eebdae40dfd68b..50b073f3f6c16a20b163f5c5d8d9cdffd1de9d20 100644 (file)
@@ -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: