diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-22 08:34:22 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-01-22 08:34:22 -0500 |
commit | e2726d99645c5fa1fd9abd6353270fde624696f8 (patch) | |
tree | 81c3ab212b91be44b180d712f43300c101e6e4d3 /tools/lib | |
parent | 566b5cfb035fb496280be61f976b5281563bfa27 (diff) |
tools lib fs: Adopt debugfs open strerrno method
As this is not specific to an evlist and may be used with other tools.
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.com>
Cc: Don Zickus <dzickus@redhat.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lkml.kernel.org/n/tip-a9up9mivx1pzdf5tqrqsx62d@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/include/asm/hash.h
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/api/fs/debugfs.c | 27 | ||||
-rw-r--r-- | tools/lib/api/fs/debugfs.h | 2 |
2 files changed, 29 insertions, 0 deletions
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c index 86ea2d7b8845..fb700eed61c2 100644 --- a/tools/lib/api/fs/debugfs.c +++ b/tools/lib/api/fs/debugfs.c | |||
@@ -1,3 +1,4 @@ | |||
1 | #define _GNU_SOURCE | ||
1 | #include <errno.h> | 2 | #include <errno.h> |
2 | #include <stdio.h> | 3 | #include <stdio.h> |
3 | #include <stdlib.h> | 4 | #include <stdlib.h> |
@@ -98,3 +99,29 @@ char *debugfs_mount(const char *mountpoint) | |||
98 | out: | 99 | out: |
99 | return debugfs_mountpoint; | 100 | return debugfs_mountpoint; |
100 | } | 101 | } |
102 | |||
103 | int debugfs__strerror_open(int err, char *buf, size_t size) | ||
104 | { | ||
105 | char sbuf[128]; | ||
106 | |||
107 | switch (err) { | ||
108 | case ENOENT: | ||
109 | snprintf(buf, size, "%s", | ||
110 | "Error:\tUnable to find debugfs\n" | ||
111 | "Hint:\tWas your kernel compiled with debugfs support?\n" | ||
112 | "Hint:\tIs the debugfs filesystem mounted?\n" | ||
113 | "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'"); | ||
114 | break; | ||
115 | case EACCES: | ||
116 | snprintf(buf, size, | ||
117 | "Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n" | ||
118 | "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", | ||
119 | debugfs_mountpoint, debugfs_mountpoint); | ||
120 | break; | ||
121 | default: | ||
122 | snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf))); | ||
123 | break; | ||
124 | } | ||
125 | |||
126 | return 0; | ||
127 | } | ||
diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h index f19d3df9609d..afa5043fec61 100644 --- a/tools/lib/api/fs/debugfs.h +++ b/tools/lib/api/fs/debugfs.h | |||
@@ -26,4 +26,6 @@ char *debugfs_mount(const char *mountpoint); | |||
26 | 26 | ||
27 | extern char debugfs_mountpoint[]; | 27 | extern char debugfs_mountpoint[]; |
28 | 28 | ||
29 | int debugfs__strerror_open(int err, char *buf, size_t size); | ||
30 | |||
29 | #endif /* __API_DEBUGFS_H__ */ | 31 | #endif /* __API_DEBUGFS_H__ */ |