tools: bpftool: attempt to mount tracefs if required for tracelog cmd
authorQuentin Monnet <quentin.monnet@netronome.com>
Tue, 18 Dec 2018 10:13:18 +0000 (10:13 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 18 Dec 2018 13:47:17 +0000 (14:47 +0100)
commitbe3245e22d227ad68ab97785d506561374daa028
tree9eb34c8d2e69fa121c94fcba5e7419dda8eda836
parent0d7410ea6efcdfda56773999f692bbd5d4e4bc00
tools: bpftool: attempt to mount tracefs if required for tracelog cmd

As a follow-up to commit 30da46b5dc3a ("tools: bpftool: add a command to
dump the trace pipe"), attempt to mount the tracefs virtual file system
if it is not detected on the system before trying to dump content of the
tracing pipe on an invocation of "bpftool prog tracelog".

Usually, tracefs in automatically mounted by debugfs when the user tries
to access it (e.g. "ls /sys/kernel/debug/tracing" mounts the tracefs).
So if we failed to find it, it is probably that debugfs is not here
either. Therefore, we just attempt a single mount, at a location that
does not involve debugfs: /sys/kernel/tracing.

Suggested-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/bpf/bpftool/common.c
tools/bpf/bpftool/main.h
tools/bpf/bpftool/tracelog.c