From 7014e0e3bf9b0d0b6221eb7d2f8a1f690423dd73 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Thu, 17 May 2018 14:42:39 -0300 Subject: tools lib api fs tracing_path: Introduce opendir() method That takes care of using the right call to get the tracing_path directory, the one that will end up calling tracing_path_set() to figure out where tracefs is mounted. One more step in doing just lazy reading of system structures to reduce the number of operations done unconditionaly at 'perf' start. Cc: Adrian Hunter Cc: David Ahern Cc: Jiri Olsa Cc: Namhyung Kim Cc: Wang Nan Link: https://lkml.kernel.org/n/tip-42zzi0f274909bg9mxzl81bu@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/api/fs/tracing_path.c | 13 +++++++++++++ tools/lib/api/fs/tracing_path.h | 3 +++ 2 files changed, 16 insertions(+) (limited to 'tools/lib') diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c index 9cd282425929..9b451af0721c 100644 --- a/tools/lib/api/fs/tracing_path.c +++ b/tools/lib/api/fs/tracing_path.c @@ -101,6 +101,19 @@ void put_events_file(char *file) free(file); } +DIR *tracing_events__opendir(void) +{ + DIR *dir = NULL; + char *path = get_tracing_file("events"); + + if (path) { + dir = opendir(path); + put_events_file(path); + } + + return dir; +} + int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name) { diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h index 3b32fb439f12..904d085b2ae7 100644 --- a/tools/lib/api/fs/tracing_path.h +++ b/tools/lib/api/fs/tracing_path.h @@ -3,9 +3,12 @@ #define __API_FS_TRACING_PATH_H #include +#include extern char tracing_events_path[]; +DIR *tracing_events__opendir(void); + void tracing_path_set(const char *mountpoint); const char *tracing_path_mount(void); -- cgit v1.2.3