8 #include <linux/string.h>
13 #include "tracing_path.h"
16 char tracing_mnt[PATH_MAX] = "/sys/kernel/debug";
17 char tracing_path[PATH_MAX] = "/sys/kernel/debug/tracing";
18 char tracing_events_path[PATH_MAX] = "/sys/kernel/debug/tracing/events";
21 static void __tracing_path_set(const char *tracing, const char *mountpoint)
23 snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
24 snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
26 snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
27 mountpoint, tracing, "events");
30 static const char *tracing_path_tracefs_mount(void)
34 mnt = tracefs__mount();
38 __tracing_path_set("", mnt);
43 static const char *tracing_path_debugfs_mount(void)
47 mnt = debugfs__mount();
51 __tracing_path_set("tracing/", mnt);
56 const char *tracing_path_mount(void)
60 mnt = tracing_path_tracefs_mount();
64 mnt = tracing_path_debugfs_mount();
69 void tracing_path_set(const char *mntpt)
71 __tracing_path_set("tracing/", mntpt);
74 char *get_tracing_file(const char *name)
78 if (asprintf(&file, "%s/%s", tracing_path, name) < 0)
84 void put_tracing_file(char *file)
89 static int strerror_open(int err, char *buf, size_t size, const char *filename)
96 * We will get here if we can't find the tracepoint, but one of
97 * debugfs or tracefs is configured, which means you probably
98 * want some tracepoint which wasn't compiled in your kernel.
101 if (debugfs__configured() || tracefs__configured()) {
103 "Error:\tFile %s/%s not found.\n"
104 "Hint:\tPerhaps this kernel misses some CONFIG_ setting to enable this feature?.\n",
105 tracing_events_path, filename);
108 snprintf(buf, size, "%s",
109 "Error:\tUnable to find debugfs/tracefs\n"
110 "Hint:\tWas your kernel compiled with debugfs/tracefs support?\n"
111 "Hint:\tIs the debugfs/tracefs filesystem mounted?\n"
112 "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
116 "Error:\tNo permissions to read %s/%s\n"
117 "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
118 tracing_events_path, filename, tracing_mnt);
122 snprintf(buf, size, "%s", str_error_r(err, sbuf, sizeof(sbuf)));
129 int tracing_path__strerror_open_tp(int err, char *buf, size_t size, const char *sys, const char *name)
133 snprintf(path, PATH_MAX, "%s/%s", sys, name ?: "*");
135 return strerror_open(err, buf, size, path);