summaryrefslogtreecommitdiffstats
path: root/sys-utils/dmesg.c
diff options
context:
space:
mode:
authorKarel Zak2012-07-20 14:41:25 +0200
committerKarel Zak2012-07-20 14:41:25 +0200
commit37b04d6cce552116f31272a56d699f7c6cc91cdf (patch)
treefe0c460c9eb7a0e709fc770f6a584d0d2db47b2f /sys-utils/dmesg.c
parentdmesg: cleanup exclusive_option() usage (diff)
downloadkernel-qcow2-util-linux-37b04d6cce552116f31272a56d699f7c6cc91cdf.tar.gz
kernel-qcow2-util-linux-37b04d6cce552116f31272a56d699f7c6cc91cdf.tar.xz
kernel-qcow2-util-linux-37b04d6cce552116f31272a56d699f7c6cc91cdf.zip
dmesg: implement backwardly compatible --raw for /dev/kmsg
.. and if you really want raw data from /dev/kmsg then use dd(1) ;-) Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/dmesg.c')
-rw-r--r--sys-utils/dmesg.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
index 70c0a2e71..65ace3e81 100644
--- a/sys-utils/dmesg.c
+++ b/sys-utils/dmesg.c
@@ -702,6 +702,16 @@ static void print_record(struct dmesg_control *ctl, struct dmesg_record *rec)
return;
}
+ if (ctl->raw) {
+ /* compose syslog(2) compatible output */
+ printf("<%d>[%5d.%06d] ",
+ LOG_MAKEPRI(rec->facility, rec->level),
+ (int) rec->tv.tv_sec,
+ (int) rec->tv.tv_usec);
+
+ goto mesg;
+ }
+
if (ctl->decode && rec->level >= 0 && rec->facility >= 0)
printf("%-6s:%-6s: ", facility_names[rec->facility].name,
level_names[rec->level].name);
@@ -744,6 +754,7 @@ static void print_record(struct dmesg_control *ctl, struct dmesg_record *rec)
!ctl->notime && !ctl->delta && !ctl->ctime)
printf("[%5d.%06d] ", (int) rec->tv.tv_sec, (int) rec->tv.tv_usec);
+mesg:
safe_fwrite(rec->mesg, rec->mesg_size, stdout);
if (*(rec->mesg + rec->mesg_size - 1) != '\n')
@@ -893,6 +904,7 @@ static int read_kmsg(struct dmesg_control *ctl)
if (parse_kmsg_record(ctl, &rec, buf, (size_t) sz) != 0)
continue;
+
print_record(ctl, &rec);
} while (1);