Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753556AbbDBNq7 (ORCPT ); Thu, 2 Apr 2015 09:46:59 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:10344 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753151AbbDBNoz (ORCPT ); Thu, 2 Apr 2015 09:44:55 -0400 From: Yunlong Song To: , , , CC: , Subject: [PATCH 10/10] perf tools: Support using -f to override perf.data file ownership for data convert Date: Thu, 2 Apr 2015 21:47:19 +0800 Message-ID: <1427982439-27388-11-git-send-email-yunlong.song@huawei.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1427982439-27388-1-git-send-email-yunlong.song@huawei.com> References: <1427982439-27388-1-git-send-email-yunlong.song@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.110.52.30] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.551D47D4.0195,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 8b01e84b8d92cae66392c065c67eea5c Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3535 Lines: 110 Enable perf data convert to use perf.data when it is not owned by current user or root. Example: # perf record ls # chown Yunlong.Song:Yunlong.Song perf.data # ls -al perf.data -rw------- 1 Yunlong.Song Yunlong.Song 28260 Apr 2 17:35 perf.data # id uid=0(root) gid=0(root) groups=0(root),64(pkcs11) Before this patch: # perf data convert --to-ctf=./ctf-data/ File perf.data not owned by current user or root (use -f to override) # perf data convert --to-ctf=./ctf-data/ -f Error: unknown switch `f' usage: perf data convert [] -v, --verbose be more verbose -i, --input input file name --to-ctf ... Convert to CTF format After this patch: # perf data convert --to-ctf=./ctf-data/ File perf.data not owned by current user or root (use -f to override) # perf data convert --to-ctf=./ctf-data/ -f # ls ctf-data/ metadata perf_stream_0 As shown above, the -f option really works now. Signed-off-by: Yunlong Song --- tools/perf/builtin-data.c | 4 +++- tools/perf/util/data-convert-bt.c | 3 ++- tools/perf/util/data-convert-bt.h | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-data.c b/tools/perf/builtin-data.c index 709152a..d6525bc 100644 --- a/tools/perf/builtin-data.c +++ b/tools/perf/builtin-data.c @@ -53,12 +53,14 @@ static int cmd_data_convert(int argc, const char **argv, const char *prefix __maybe_unused) { const char *to_ctf = NULL; + bool force = false; const struct option options[] = { OPT_INCR('v', "verbose", &verbose, "be more verbose"), OPT_STRING('i', "input", &input_name, "file", "input file name"), #ifdef HAVE_LIBBABELTRACE_SUPPORT OPT_STRING(0, "to-ctf", &to_ctf, NULL, "Convert to CTF format"), #endif + OPT_BOOLEAN('f', "force", &force, "don't complain, do it"), OPT_END() }; @@ -76,7 +78,7 @@ static int cmd_data_convert(int argc, const char **argv, if (to_ctf) { #ifdef HAVE_LIBBABELTRACE_SUPPORT - return bt_convert__perf2ctf(input_name, to_ctf); + return bt_convert__perf2ctf(input_name, to_ctf, force); #else pr_err("The libbabeltrace support is not compiled in.\n"); return -1; diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c index c6d6226..dd17c9a 100644 --- a/tools/perf/util/data-convert-bt.c +++ b/tools/perf/util/data-convert-bt.c @@ -791,12 +791,13 @@ err: return -1; } -int bt_convert__perf2ctf(const char *input, const char *path) +int bt_convert__perf2ctf(const char *input, const char *path, bool force) { struct perf_session *session; struct perf_data_file file = { .path = input, .mode = PERF_DATA_MODE_READ, + .force = force, }; struct convert c = { .tool = { diff --git a/tools/perf/util/data-convert-bt.h b/tools/perf/util/data-convert-bt.h index dda30c5..4c20434 100644 --- a/tools/perf/util/data-convert-bt.h +++ b/tools/perf/util/data-convert-bt.h @@ -2,7 +2,7 @@ #define __DATA_CONVERT_BT_H #ifdef HAVE_LIBBABELTRACE_SUPPORT -int bt_convert__perf2ctf(const char *input_name, const char *to_ctf); +int bt_convert__perf2ctf(const char *input_name, const char *to_ctf, bool force); #endif /* HAVE_LIBBABELTRACE_SUPPORT */ #endif /* __DATA_CONVERT_BT_H */ -- 1.8.5.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/