aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/lib/api/fs/tracing_path.c15
-rw-r--r--tools/lib/api/fs/tracing_path.h5
-rw-r--r--tools/perf/util/trace-event-info.c11
3 files changed, 25 insertions, 6 deletions
diff --git a/tools/lib/api/fs/tracing_path.c b/tools/lib/api/fs/tracing_path.c
index 6f5fe942eff4..9cd282425929 100644
--- a/tools/lib/api/fs/tracing_path.c
+++ b/tools/lib/api/fs/tracing_path.c
@@ -86,6 +86,21 @@ void put_tracing_file(char *file)
86 free(file); 86 free(file);
87} 87}
88 88
89char *get_events_file(const char *name)
90{
91 char *file;
92
93 if (asprintf(&file, "%s/events/%s", tracing_path_mount(), name) < 0)
94 return NULL;
95
96 return file;
97}
98
99void put_events_file(char *file)
100{
101 free(file);
102}
103
89int tracing_path__strerror_open_tp(int err, char *buf, size_t size, 104int tracing_path__strerror_open_tp(int err, char *buf, size_t size,
90 const char *sys, const char *name) 105 const char *sys, const char *name)
91{ 106{
diff --git a/tools/lib/api/fs/tracing_path.h b/tools/lib/api/fs/tracing_path.h
index 1b65decedfc0..3b32fb439f12 100644
--- a/tools/lib/api/fs/tracing_path.h
+++ b/tools/lib/api/fs/tracing_path.h
@@ -12,5 +12,10 @@ const char *tracing_path_mount(void);
12char *get_tracing_file(const char *name); 12char *get_tracing_file(const char *name);
13void put_tracing_file(char *file); 13void put_tracing_file(char *file);
14 14
15char *get_events_file(const char *name);
16void put_events_file(char *file);
17
18#define zput_events_file(ptr) ({ free(*ptr); *ptr = NULL; })
19
15int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name); 20int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name);
16#endif /* __API_FS_TRACING_PATH_H */ 21#endif /* __API_FS_TRACING_PATH_H */
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c
index d7f2113462fb..c85d0d1a65ed 100644
--- a/tools/perf/util/trace-event-info.c
+++ b/tools/perf/util/trace-event-info.c
@@ -103,11 +103,10 @@ out:
103 103
104static int record_header_files(void) 104static int record_header_files(void)
105{ 105{
106 char *path; 106 char *path = get_events_file("header_page");
107 struct stat st; 107 struct stat st;
108 int err = -EIO; 108 int err = -EIO;
109 109
110 path = get_tracing_file("events/header_page");
111 if (!path) { 110 if (!path) {
112 pr_debug("can't get tracing/events/header_page"); 111 pr_debug("can't get tracing/events/header_page");
113 return -ENOMEM; 112 return -ENOMEM;
@@ -128,9 +127,9 @@ static int record_header_files(void)
128 goto out; 127 goto out;
129 } 128 }
130 129
131 put_tracing_file(path); 130 put_events_file(path);
132 131
133 path = get_tracing_file("events/header_event"); 132 path = get_events_file("header_event");
134 if (!path) { 133 if (!path) {
135 pr_debug("can't get tracing/events/header_event"); 134 pr_debug("can't get tracing/events/header_event");
136 err = -ENOMEM; 135 err = -ENOMEM;
@@ -154,7 +153,7 @@ static int record_header_files(void)
154 153
155 err = 0; 154 err = 0;
156out: 155out:
157 put_tracing_file(path); 156 put_events_file(path);
158 return err; 157 return err;
159} 158}
160 159
@@ -243,7 +242,7 @@ static int record_ftrace_files(struct tracepoint_path *tps)
243 char *path; 242 char *path;
244 int ret; 243 int ret;
245 244
246 path = get_tracing_file("events/ftrace"); 245 path = get_events_file("ftrace");
247 if (!path) { 246 if (!path) {
248 pr_debug("can't get tracing/events/ftrace"); 247 pr_debug("can't get tracing/events/ftrace");
249 return -ENOMEM; 248 return -ENOMEM;