[Toybox] [PATCH] dmesg: add -t suppress timestamp flag

enh enh at google.com
Sun May 3 13:43:56 PDT 2015


[+list]

existing practice seems to vary between "group by functionality"
(which would group -r and -t but not -c) and "group by syntax" (which
would group them all together).

-C (which is unimplemented in toybox) is definitely different, because
it doesn't show you the log. -c is weird though. even if you're
grouping by functionality, it could be argued to belong with -r and -t
because although it doesn't change the output, you still get output,
and it just happens that the log is cleared as a side-effect. the
util-linux dmesg avoids the issue by just saying "dmesg [options]".

speaking of -c...

Fix dmesg -c error output.

Use perror_exit to show the likely "Operation not permitted" if klogctl fails.

diff --git a/toys/lsb/dmesg.c b/toys/lsb/dmesg.c
index 50da8a8..cbb21bf 100644
--- a/toys/lsb/dmesg.c
+++ b/toys/lsb/dmesg.c
@@ -48,7 +48,7 @@ void dmesg_main(void)
     if (!size && 1>(size = klogctl(10, 0, 0))) perror_exit("klogctl");;
     data = to = from = xmalloc(size+1);
     size = klogctl(3 + (toys.optflags & FLAG_c), data, size);
-    if (size < 0) error_exit("klogctl");
+    if (size < 0) perror_exit("klogctl");
     data[size] = 0;

     // Filter out level markers and optionally time markers



On Sat, May 2, 2015 at 11:27 PM, Christopher Barry
<christopher.r.barry at gmail.com> wrote:
> On Sat, 2 May 2015 10:49:48 -0700
> enh <enh at google.com> wrote:
>
>>usage: dmesg [-n LEVEL] [-s SIZE] [-r|-t] | -c
>
> is not -r|-t|-c the same thing?
>
> --
> Regards,
> Christopher Barry
>
> Random geeky fortune:
> Substantial penalty for early withdrawal.



-- 
Elliott Hughes - http://who/enh - http://jessies.org/~enh/
Android native code/tools questions? Mail me/drop by/add me as a reviewer.

 1430685836.0


More information about the Toybox mailing list