Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Adrian Hunter and committed by
Arnaldo Carvalho de Melo
a4455e00 180b3d06

+15
+14
tools/perf/util/data.c
··· 479 479 return mkdir(buf, S_IRWXU); 480 480 } 481 481 482 + bool has_kcore_dir(const char *path) 483 + { 484 + char *kcore_dir; 485 + int ret; 486 + 487 + if (asprintf(&kcore_dir, "%s/kcore_dir", path) < 0) 488 + return false; 489 + 490 + ret = access(kcore_dir, F_OK); 491 + 492 + free(kcore_dir); 493 + return !ret; 494 + } 495 + 482 496 char *perf_data__kallsyms_name(struct perf_data *data) 483 497 { 484 498 char *kallsyms_name;
+1
tools/perf/util/data.h
··· 99 99 int perf_data__update_dir(struct perf_data *data); 100 100 unsigned long perf_data__size(struct perf_data *data); 101 101 int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz); 102 + bool has_kcore_dir(const char *path); 102 103 char *perf_data__kallsyms_name(struct perf_data *data); 103 104 bool is_perf_data(const char *path); 104 105 #endif /* __PERF_DATA_H */