aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tools/lib/api/fs/debugfs.c28
-rw-r--r--tools/lib/api/fs/debugfs.h1
-rw-r--r--tools/perf/util/parse-events.c19
3 files changed, 14 insertions, 34 deletions
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c
index d2b18e887071..d21d4d6b4fd2 100644
--- a/tools/lib/api/fs/debugfs.c
+++ b/tools/lib/api/fs/debugfs.c
@@ -20,6 +20,20 @@ static const char * const debugfs_known_mountpoints[] = {
20 20
21static bool debugfs_found; 21static bool debugfs_found;
22 22
23/* verify that a mountpoint is actually a debugfs instance */
24
25static int debugfs_valid_mountpoint(const char *debugfs)
26{
27 struct statfs st_fs;
28
29 if (statfs(debugfs, &st_fs) < 0)
30 return -ENOENT;
31 else if ((long)st_fs.f_type != (long)DEBUGFS_MAGIC)
32 return -ENOENT;
33
34 return 0;
35}
36
23/* find the path to the mounted debugfs */ 37/* find the path to the mounted debugfs */
24const char *debugfs_find_mountpoint(void) 38const char *debugfs_find_mountpoint(void)
25{ 39{
@@ -60,20 +74,6 @@ const char *debugfs_find_mountpoint(void)
60 return debugfs_mountpoint; 74 return debugfs_mountpoint;
61} 75}
62 76
63/* verify that a mountpoint is actually a debugfs instance */
64
65int debugfs_valid_mountpoint(const char *debugfs)
66{
67 struct statfs st_fs;
68
69 if (statfs(debugfs, &st_fs) < 0)
70 return -ENOENT;
71 else if ((long)st_fs.f_type != (long)DEBUGFS_MAGIC)
72 return -ENOENT;
73
74 return 0;
75}
76
77/* mount the debugfs somewhere if it's not mounted */ 77/* mount the debugfs somewhere if it's not mounted */
78char *debugfs_mount(const char *mountpoint) 78char *debugfs_mount(const char *mountpoint)
79{ 79{
diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h
index 0739881a9897..77bb36a95b07 100644
--- a/tools/lib/api/fs/debugfs.h
+++ b/tools/lib/api/fs/debugfs.h
@@ -21,7 +21,6 @@
21#endif 21#endif
22 22
23const char *debugfs_find_mountpoint(void); 23const char *debugfs_find_mountpoint(void);
24int debugfs_valid_mountpoint(const char *debugfs);
25char *debugfs_mount(const char *mountpoint); 24char *debugfs_mount(const char *mountpoint);
26 25
27extern char debugfs_mountpoint[]; 26extern char debugfs_mountpoint[];
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 7f8ec6ce2823..ecf069b1661f 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -175,9 +175,6 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
175 char evt_path[MAXPATHLEN]; 175 char evt_path[MAXPATHLEN];
176 char dir_path[MAXPATHLEN]; 176 char dir_path[MAXPATHLEN];
177 177
178 if (debugfs_valid_mountpoint(tracing_events_path))
179 return NULL;
180
181 sys_dir = opendir(tracing_events_path); 178 sys_dir = opendir(tracing_events_path);
182 if (!sys_dir) 179 if (!sys_dir)
183 return NULL; 180 return NULL;
@@ -473,12 +470,6 @@ static int add_tracepoint_multi_sys(struct list_head *list, int *idx,
473int parse_events_add_tracepoint(struct list_head *list, int *idx, 470int parse_events_add_tracepoint(struct list_head *list, int *idx,
474 char *sys, char *event) 471 char *sys, char *event)
475{ 472{
476 int ret;
477
478 ret = debugfs_valid_mountpoint(tracing_events_path);
479 if (ret)
480 return ret;
481
482 if (strpbrk(sys, "*?")) 473 if (strpbrk(sys, "*?"))
483 return add_tracepoint_multi_sys(list, idx, sys, event); 474 return add_tracepoint_multi_sys(list, idx, sys, event);
484 else 475 else
@@ -1109,13 +1100,6 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob,
1109 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent; 1100 struct dirent *sys_next, *evt_next, sys_dirent, evt_dirent;
1110 char evt_path[MAXPATHLEN]; 1101 char evt_path[MAXPATHLEN];
1111 char dir_path[MAXPATHLEN]; 1102 char dir_path[MAXPATHLEN];
1112 char sbuf[STRERR_BUFSIZE];
1113
1114 if (debugfs_valid_mountpoint(tracing_events_path)) {
1115 printf(" [ Tracepoints not available: %s ]\n",
1116 strerror_r(errno, sbuf, sizeof(sbuf)));
1117 return;
1118 }
1119 1103
1120 sys_dir = opendir(tracing_events_path); 1104 sys_dir = opendir(tracing_events_path);
1121 if (!sys_dir) 1105 if (!sys_dir)
@@ -1163,9 +1147,6 @@ int is_valid_tracepoint(const char *event_string)
1163 char evt_path[MAXPATHLEN]; 1147 char evt_path[MAXPATHLEN];
1164 char dir_path[MAXPATHLEN]; 1148 char dir_path[MAXPATHLEN];
1165 1149
1166 if (debugfs_valid_mountpoint(tracing_events_path))
1167 return 0;
1168
1169 sys_dir = opendir(tracing_events_path); 1150 sys_dir = opendir(tracing_events_path);
1170 if (!sys_dir) 1151 if (!sys_dir)
1171 return 0; 1152 return 0;