.SH NAME
dmesg \- print or control the kernel ring buffer
.SH SYNOPSIS
-.BI "dmesg [ \-c ] [ \-n " level " ] [ \-s " bufsize " ]"
+.BI "dmesg [ \-c ] [ -r ] [ \-n " level " ] [ \-s " bufsize " ]"
.SH DESCRIPTION
.B dmesg
is used to examine or control the kernel ring buffer.
.B \-c
Clear the ring buffer contents after printing.
.TP
+.B \-r
+Print the raw message buffer, i.e., don't strip the log level prefixes.
+.TP
.BI \-s bufsize
Use a buffer of size
.I bufsize
int level = 0;
int lastc;
int cmd = 3; /* Read all messages in the ring buffer */
+ int raw = 0;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
progname = argv[0];
- while ((c = getopt(argc, argv, "cn:s:")) != -1) {
+ while ((c = getopt(argc, argv, "crn:s:")) != -1) {
switch (c) {
case 'c':
cmd = 4; /* Read and clear all messages */
cmd = 8; /* Set level of messages */
level = atoi(optarg);
break;
+ case 'r':
+ raw = 1;
+ break;
case 's':
bufsize = atoi(optarg);
if (bufsize < 4096)
lastc = '\n';
for (i = 0; i < n; i++) {
- if ((i == 0 || buf[i - 1] == '\n') && buf[i] == '<') {
+ if (!raw && (i == 0 || buf[i - 1] == '\n') && buf[i] == '<') {
i++;
while (buf[i] >= '0' && buf[i] <= '9')
i++;