trace: add variant without spacing in trace_print_hex_seq

For upcoming tracepoint support for BPF, we want to dump the program's
tag. Format should be similar to __print_hex(), but without spacing.
Add a __print_hex_str() variant for exactly that purpose that reuses
trace_print_hex_seq().

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Daniel Borkmann
2017-01-25 02:28:16 +01:00
committed by David S. Miller
parent 60b1af3300
commit 2acae0d5b0
3 changed files with 13 additions and 5 deletions

View File

@@ -163,14 +163,15 @@ trace_print_bitmask_seq(struct trace_seq *p, void *bitmask_ptr,
EXPORT_SYMBOL_GPL(trace_print_bitmask_seq);
const char *
trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len)
trace_print_hex_seq(struct trace_seq *p, const unsigned char *buf, int buf_len,
bool spacing)
{
int i;
const char *ret = trace_seq_buffer_ptr(p);
for (i = 0; i < buf_len; i++)
trace_seq_printf(p, "%s%2.2x", i == 0 ? "" : " ", buf[i]);
trace_seq_printf(p, "%s%2.2x", !spacing || i == 0 ? "" : " ",
buf[i]);
trace_seq_putc(p, 0);
return ret;