diff options
author | Tommi Rantala <tommi.t.rantala@nokia.com> | 2017-03-22 14:06:24 +0100 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-03-27 20:37:54 +0200 |
commit | 55f77128e7652e537d6c226d5b56821cdb5c22de (patch) | |
tree | 7a66bdfb40a15766eaf910a66da46cd1e38c968f /tools/perf/util | |
parent | perf utils: Null terminate buf in read_ftrace_printk() (diff) | |
download | linux-55f77128e7652e537d6c226d5b56821cdb5c22de.tar.xz linux-55f77128e7652e537d6c226d5b56821cdb5c22de.zip |
perf utils: Readlink /proc/self/exe to find the perf binary
Simplification: it is easier to open /proc/self/exe than /proc/$pid/exe.
Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/20170322130624.21881-7-tommi.t.rantala@nokia.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util')
-rw-r--r-- | tools/perf/util/header.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index cf22962ce725..ef09f26e67da 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -370,15 +370,11 @@ static int write_cmdline(int fd, struct perf_header *h __maybe_unused, struct perf_evlist *evlist __maybe_unused) { char buf[MAXPATHLEN]; - char proc[32]; u32 n; int i, ret; - /* - * actual atual path to perf binary - */ - sprintf(proc, "/proc/%d/exe", getpid()); - ret = readlink(proc, buf, sizeof(buf) - 1); + /* actual path to perf binary */ + ret = readlink("/proc/self/exe", buf, sizeof(buf) - 1); if (ret <= 0) return -1; |