]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - tools/perf/util/header.c
perf tools: Add perf_exe() helper to find perf binary
[linux.git] / tools / perf / util / header.c
index a2323d777dae274885ed92daae1b5d2174dc79d0..01b324c275b9d1ba0bd771f30b49952550038295 100644 (file)
@@ -527,17 +527,11 @@ static int write_event_desc(struct feat_fd *ff,
 static int write_cmdline(struct feat_fd *ff,
                         struct perf_evlist *evlist __maybe_unused)
 {
-       char buf[MAXPATHLEN];
-       u32 n;
-       int i, ret;
+       char pbuf[MAXPATHLEN], *buf;
+       int i, ret, n;
 
        /* actual path to perf binary */
-       ret = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
-       if (ret <= 0)
-               return -1;
-
-       /* readlink() does not add null termination */
-       buf[ret] = '\0';
+       buf = perf_exe(pbuf, MAXPATHLEN);
 
        /* account for binary path */
        n = perf_env.nr_cmdline + 1;