From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754365AbdC1GDp (ORCPT ); Tue, 28 Mar 2017 02:03:45 -0400 Received: from terminus.zytor.com ([65.50.211.136]:45039 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752760AbdC1GDm (ORCPT ); Tue, 28 Mar 2017 02:03:42 -0400 Date: Mon, 27 Mar 2017 22:59:01 -0700 From: tip-bot for Tommi Rantala Message-ID: Cc: tommi.t.rantala@nokia.com, alexander.shishkin@linux.intel.com, hpa@zytor.com, acme@redhat.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de Reply-To: mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, tommi.t.rantala@nokia.com, alexander.shishkin@linux.intel.com, hpa@zytor.com, acme@redhat.com In-Reply-To: <20170322130624.21881-7-tommi.t.rantala@nokia.com> References: <20170322130624.21881-7-tommi.t.rantala@nokia.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf utils: Readlink /proc/self/exe to find the perf binary Git-Commit-ID: 55f77128e7652e537d6c226d5b56821cdb5c22de X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 55f77128e7652e537d6c226d5b56821cdb5c22de Gitweb: http://git.kernel.org/tip/55f77128e7652e537d6c226d5b56821cdb5c22de Author: Tommi Rantala AuthorDate: Wed, 22 Mar 2017 15:06:24 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 27 Mar 2017 15:37:54 -0300 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 --- tools/perf/util/header.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) 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;