diff options
author | Andi Kleen <ak@linux.intel.com> | 2019-02-24 18:37:19 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2019-02-25 16:58:28 +0300 |
commit | 94816add0005595ea33fc8456519be582330401e (patch) | |
tree | 2b6d96ee56bb88f1c4e1044b5ef62a29528d65bb /tools/perf/util/util.c | |
parent | 4b6ac811bce46c83811b83cdf87b41251596b9fc (diff) | |
download | linux-94816add0005595ea33fc8456519be582330401e.tar.xz |
perf tools: Add perf_exe() helper to find perf binary
Also convert one existing user.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/r/20190224153722.27020-9-andi@firstfloor.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/util.c')
-rw-r--r-- | tools/perf/util/util.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c index 706818693086..d388f80d8703 100644 --- a/tools/perf/util/util.c +++ b/tools/perf/util/util.c @@ -568,3 +568,13 @@ out: return tip; } + +char *perf_exe(char *buf, int len) +{ + int n = readlink("/proc/self/exe", buf, len); + if (n > 0) { + buf[n] = 0; + return buf; + } + return strcpy(buf, "perf"); +} |