]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
dmesg: add --console-on and --console-off
authorKarel Zak <kzak@redhat.com>
Fri, 1 Jul 2011 13:30:16 +0000 (15:30 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Jul 2011 13:30:16 +0000 (15:30 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/dmesg.1
sys-utils/dmesg.c

index 85f4dc04df3d763f5410b9d7fc35a7e8d30fa6b8..a593485c1a798208a59b44c7abbab93f40373fbd 100644 (file)
@@ -14,6 +14,10 @@ dmesg \- print or control the kernel ring buffer
 .sp
 .B dmesg \-\-console-level
 .I level
+.sp
+.B dmesg \-\-console-on
+.sp
+.B dmesg \-\-console-off
 .SH DESCRIPTION
 .B dmesg
 is used to examine or control the kernel ring buffer.
@@ -21,12 +25,17 @@ is used to examine or control the kernel ring buffer.
 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.
+The --clear, --read-clear, --console-on, --console-off and --console-level
+options are mutually exclusive.
 
 .IP "\fB\-C, \-\-clear\fP"
 Clear the ring buffer.
 .IP "\fB\-c, \-\-read-clear\fP"
 Clear the ring buffer contents after printing.
+.IP "\fB\-d, \-\-console-off\fP"
+Disable printing messages to the console.
+.IP "\fB\-e, \-\-console-on\fP"
+Enable printing messages to the console.
 .IP "\fB\-h, \-\-help\fP"
 Print a help text and exit.
 .IP "\fB\-n, \-\-console-level \fIlevel\fP
index 50b073f3f6c16a20b163f5c5d8d9cdffd1de9d20..fde11100fe360e71bda35d578fbdc512d6482d39 100644 (file)
@@ -59,11 +59,13 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
                "\nOptions:\n"
                " -C, --clear               clear the kernel ring buffer\n"
                " -c, --read-clear          read and clear all messages\n"
+               " -d, --console-off         disable printing messages to console\n"
+               " -e, --console-on          enable printing messages to console\n"
+               " -h, --help                display this help and exit\n"
+               " -n, --console-level=LEVEL set level of messages printed to console\n"
                " -r, --raw                 print the raw message buffer\n"
                " -s, --buffer-size=SIZE    buffer size to query the kernel ring buffer\n"
-               " -n, --console-level=LEVEL set level of messages printed to console\n"
-               " -V, --version             output version information and exit\n"
-               " -h, --help                display this help and exit\n\n"));
+               " -V, --version             output version information and exit\n\n"));
 
        exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
 }
@@ -142,6 +144,8 @@ int main(int argc, char *argv[])
                { "raw",           no_argument,       NULL, 'r' },
                { "buffer-size",   required_argument, NULL, 's' },
                { "console-level", required_argument, NULL, 'n' },
+               { "console-off",   no_argument,       NULL, 'd' },
+               { "console-on",    no_argument,       NULL, 'e' },
                { "version",       no_argument,       NULL, 'V' },
                { "help",          no_argument,       NULL, 'h' },
                { NULL,            0, NULL, 0 }
@@ -151,11 +155,11 @@ int main(int argc, char *argv[])
        bindtextdomain(PACKAGE, LOCALEDIR);
        textdomain(PACKAGE);
 
-       while ((c = getopt_long(argc, argv, "Cchrn:s:V", longopts, NULL)) != -1) {
+       while ((c = getopt_long(argc, argv, "Ccdehrn:s:V", longopts, NULL)) != -1) {
 
-               if (cmd != -1 && strchr("Ccn", c))
+               if (cmd != -1 && strchr("Ccnde", c))
                        errx(EXIT_FAILURE, "%s %s",
-                               "--{clear,read-clear,console-level}",
+                               "--{clear,read-clear,console-level,console-on,console-off}",
                                _("options are mutually exclusive"));
 
                switch (c) {
@@ -165,6 +169,12 @@ int main(int argc, char *argv[])
                case 'c':
                        cmd = SYSLOG_ACTION_READ_CLEAR;
                        break;
+               case 'd':
+                       cmd = SYSLOG_ACTION_CONSOLE_OFF;
+                       break;
+               case 'e':
+                       cmd = SYSLOG_ACTION_CONSOLE_ON;
+                       break;
                case 'n':
                        cmd = SYSLOG_ACTION_CONSOLE_LEVEL;
                        console_level = strtol_or_err(optarg,
@@ -211,6 +221,8 @@ int main(int argc, char *argv[])
                free(buf);
                break;
        case SYSLOG_ACTION_CLEAR:
+       case SYSLOG_ACTION_CONSOLE_OFF:
+       case SYSLOG_ACTION_CONSOLE_ON:
                n = klogctl(cmd, NULL, 0);
                break;
        case SYSLOG_ACTION_CONSOLE_LEVEL: