[Toybox] [PATCH] Implement "dmesg -w".

enh enh at google.com
Tue Nov 15 10:11:12 PST 2016


(sorry, was afk, including linux plumbers, keeping up the tradition of
us going in alternating years :-) )

On Sun, Oct 30, 2016 at 6:00 PM, Rob Landley <rob at landley.net> wrote:
> On 10/28/2016 06:04 PM, enh wrote:
>> Annoyingly, this means writing a new dmesg implementation that uses /dev/kmsg
>> rather than the klogctl system call. Worse, pre-3.5 kernels don't support
>> that, so we need to keep the old implementation around as long as we still
>> care about those kernels.
>
> Sigh. Let's see, new api...
>
> https://www.kernel.org/doc/Documentation/ABI/testing/dev-kmsg
>
> (Which is the official location for that, by the way. free-electrons is
> nice but if kernel.org is going to provide it...)
>
> It's from this guy:
>
> http://www.theregister.co.uk/2014/04/05/torvalds_sievers_dust_up/
>
> This should end well.
>
>> Since I'm here, add the fancy colors from modern dmesg and the -C flag.
>
> There's no way _not_ to color the output except piping it through cat.

yeah, it's the usual --color=[never|auto|always]. i was going to copy
what ls did (as the main user of --color=[never|auto|always]), but it
looked like ls doesn't quite work like that yet either, and i wasn't
sure what your plan was there?

> I assume dmesg -cC is allowed? And -Crtw etc? Ubuntu 14.04 hasn't got a
> -w so I can't test that, but:
>
>   $ dmesg -Crt
>   dmesg: --raw can't be used together with level, facility, decode,
>   delta, ctime or notime options

(makes sense that "raw" [which really isn't any such thing] would be
treated as another output format specifier and be mutually exclusive
with the others.)

> Sigh, I need to upgrade lib/args.c to have a syntax to say "these
> letters all conflict with the _first_ letter but not each other". [$abc]
> maybe? Throw it on the todo heap... (Still neck-deep in GPS-land for
> another week. Learning to calculating the G2 register of the LFSR for a
> given PRN value. No really, those all mean something. Unfortunatley the
> example program the hardware engineer wrote for us was written in bad perl.)
>
> I can't easily test legacy_mode() but it looks like TT.size is never set
> if you don't specify -s (defaults to 0) and it'll perror_exit("klogctl")
> in that case?

yeah, some of the options are incompatible, and whether or not you can
use -w depends on your kernel version. i assume you still want to
support "old" (pre-3.5) kernels?

i wanted the new implementation to get plenty of use to help shake the
bugs out, but it might make sense -- if we're keeping the pre-3.5
support -- to only use it with -w.

> Poking at it...
>
> Rob
> _______________________________________________
> Toybox mailing list
> Toybox at lists.landley.net
> http://lists.landley.net/listinfo.cgi/toybox-landley.net



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



More information about the Toybox mailing list