From: Tommi Rantala Date: Wed, 22 Mar 2017 13:06:24 +0000 (+0200) Subject: perf utils: Readlink /proc/self/exe to find the perf binary X-Git-Tag: v5.15~11434^2~32^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55f77128e7652e537d6c226d5b56821cdb5c22de;p=platform%2Fkernel%2Flinux-starfive.git 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 Cc: Alexander Shishkin Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20170322130624.21881-7-tommi.t.rantala@nokia.com Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index cf22962..ef09f26 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;