perf data: Add has_kcore_dir()
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> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lore.kernel.org/r/20220520132404.25853-5-adrian.hunter@intel.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
180b3d0626
commit
a4455e0053
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue