ubase

suckless linux base utils
git clone git://git.2f30.org/ubase
Log | Files | Refs | README | LICENSE

commit 5c73758bba3cabadd34871c0361b938c05282168
parent 41d82175fcc897dd939760a14cb2190820488711
Author: sin <sin@2f30.org>
Date:   Sat, 17 Aug 2013 17:22:30 +0100

Add raw flag for dmesg

Diffstat:
Mdmesg.c | 17+++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/dmesg.c b/dmesg.c @@ -18,7 +18,7 @@ enum { static void usage(void) { - eprintf("usage: [-Cc] %s\n", argv0); + eprintf("usage: [-Ccr] %s\n", argv0); } int @@ -27,6 +27,7 @@ main(int argc, char *argv[]) int n; char *buf; int cflag = 0; + int rflag = 0; ARGBEGIN { case 'C': @@ -36,6 +37,9 @@ main(int argc, char *argv[]) case 'c': cflag = 1; break; + case 'r': + rflag = 1; + break; default: usage(); } ARGEND; @@ -52,9 +56,14 @@ main(int argc, char *argv[]) if (n < 0) eprintf("klogctl:"); - n = dmesg_show(STDOUT_FILENO, buf, n); - if (n < 0) - eprintf("dmesg_show:"); + if (rflag) { + if (write(STDOUT_FILENO, buf, n) != n) + eprintf("write:"); + } else { + n = dmesg_show(STDOUT_FILENO, buf, n); + if (n < 0) + eprintf("dmesg_show:"); + } if (cflag && klogctl(SYSLOG_ACTION_CLEAR, NULL, 0) < 0) eprintf("klogctl:");