From: Adrian Hunter <adrian.hunter@intel.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] perf data: Add has_kcore_dir()
Date: Fri, 20 May 2022 16:24:03 +0300 [thread overview]
Message-ID: <20220520132404.25853-5-adrian.hunter@intel.com> (raw)
In-Reply-To: <20220520132404.25853-1-adrian.hunter@intel.com>
Add a helper function has_kcore_dir(), so that perf inject can determine if
it needs to keep the kcore_dir.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
tools/perf/util/data.c | 14 ++++++++++++++
tools/perf/util/data.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index a5ace2bbc28d..caabeac24c69 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -479,6 +479,20 @@ int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz)
return mkdir(buf, S_IRWXU);
}
+bool has_kcore_dir(const char *path)
+{
+ char *kcore_dir;
+ int ret;
+
+ if (asprintf(&kcore_dir, "%s/kcore_dir", path) < 0)
+ return false;
+
+ ret = access(kcore_dir, F_OK);
+
+ free(kcore_dir);
+ return !ret;
+}
+
char *perf_data__kallsyms_name(struct perf_data *data)
{
char *kallsyms_name;
diff --git a/tools/perf/util/data.h b/tools/perf/util/data.h
index 1402d9657ef2..7de53d6e2d7f 100644
--- a/tools/perf/util/data.h
+++ b/tools/perf/util/data.h
@@ -99,6 +99,7 @@ void perf_data__close_dir(struct perf_data *data);
int perf_data__update_dir(struct perf_data *data);
unsigned long perf_data__size(struct perf_data *data);
int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz);
+bool has_kcore_dir(const char *path);
char *perf_data__kallsyms_name(struct perf_data *data);
bool is_perf_data(const char *path);
#endif /* __PERF_DATA_H */
--
2.25.1
next prev parent reply other threads:[~2022-05-20 13:24 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-20 13:23 [PATCH 0/5] perf inject: Minor improvements Adrian Hunter
2022-05-20 13:24 ` [PATCH 1/5] perf header: Add ability to keep feature sections Adrian Hunter
2022-05-20 13:24 ` [PATCH 2/5] libperf: Add preadn() Adrian Hunter
2022-05-20 13:55 ` David Laight
2022-05-20 15:56 ` [PATCH V2 " Adrian Hunter
2022-05-20 13:24 ` [PATCH 3/5] perf inject: Keep some features sections from input file Adrian Hunter
2022-05-23 8:14 ` Jiri Olsa
2022-05-23 9:23 ` Adrian Hunter
2022-05-20 13:24 ` Adrian Hunter [this message]
2022-05-20 13:24 ` [PATCH 5/5] perf inject: Keep a copy of kcore_dir Adrian Hunter
2022-05-23 8:16 ` [PATCH 0/5] perf inject: Minor improvements Jiri Olsa
2022-05-23 13:12 ` Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220520132404.25853-5-adrian.hunter@intel.com \
--to=adrian.hunter@intel.com \
--cc=acme@kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox