diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2018-11-30 16:25:44 +0000 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2018-11-30 14:06:06 -0800 |
commit | 327e5dab6dd8559ba28739ec8873350d7b5bb080 (patch) | |
tree | 370cef3a25e60fa348730d04ee1561b7f726d705 /tools/bpf/bpftool/jit_disasm.c | |
parent | cc2b8ed1369592fb84609e920f99a5659a6445f7 (diff) | |
download | linux-327e5dab6dd8559ba28739ec8873350d7b5bb080.tar.bz2 |
tools: bpftool: use "/proc/self/" i.o. crafting links with getpid()
The getpid() function is called in a couple of places in bpftool to
craft links of the shape "/proc/<pid>/...". Instead, it is possible to
use the "/proc/self/" shortcut, which makes things a bit easier, in
particular in jit_disasm.c.
Do the replacement, and remove the includes of <sys/types.h> from the
relevant files, now we do not use getpid() anymore.
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/jit_disasm.c')
-rw-r--r-- | tools/bpf/bpftool/jit_disasm.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c index b2ed5ee1af5f..545a92471c33 100644 --- a/tools/bpf/bpftool/jit_disasm.c +++ b/tools/bpf/bpftool/jit_disasm.c @@ -19,7 +19,6 @@ #include <string.h> #include <bfd.h> #include <dis-asm.h> -#include <sys/types.h> #include <sys/stat.h> #include <limits.h> @@ -28,20 +27,12 @@ static void get_exec_path(char *tpath, size_t size) { + const char *path = "/proc/self/exe"; ssize_t len; - char *path; - - snprintf(tpath, size, "/proc/%d/exe", (int) getpid()); - tpath[size - 1] = 0; - - path = strdup(tpath); - assert(path); len = readlink(path, tpath, size - 1); assert(len > 0); tpath[len] = 0; - - free(path); } static int oper_count; |