diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-07-06 07:51:41 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-07-06 11:22:14 -0400 |
commit | ab85785aa13c36440a91a8e9f7616357de411a1f (patch) | |
tree | e12b993f3ca7ce4df2abf0b077e569cdf91e0988 /tools/lib/api/fs | |
parent | 3abebc55d70b6e3247d1f0e34c0bb906e40d2a18 (diff) |
tools lib api debugfs: Check for tracefs when reporting errors
Now that we have two mountpoints, one for debugfs and another, for
tracefs, we end up needing to check permissions for both, so, on
a system with default config we were always asking the user to
check the permission of the debugfs mountpoint, even when it was
already sufficient. Fix it.
E.g.:
$ trace -e nanosleep usleep 1
Error: No permissions to read /sys/kernel/debug/tracing/events/raw_syscalls/sys_(enter|exit)
Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug'
$ sudo mount -o remount,mode=755 /sys/kernel/debug
$ trace -e nanosleep usleep 1
Error: No permissions to read /sys/kernel/debug/tracing/events/raw_syscalls/sys_(enter|exit)
Hint: Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'
$ sudo mount -o remount,mode=755 /sys/kernel/debug/tracing
$ trace -e nanosleep usleep 1
0.326 ( 0.061 ms): usleep/11961 nanosleep(rqtp: 0x7ffef1081c50) = 0
$
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: David Ahern <dsahern@gmail.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>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-0viljeuhc7q84ic8kobsna43@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/api/fs')
-rw-r--r-- | tools/lib/api/fs/debugfs.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c index 8305b3e9d48e..eb7cf4d18f8a 100644 --- a/tools/lib/api/fs/debugfs.c +++ b/tools/lib/api/fs/debugfs.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | 13 | ||
14 | #include "debugfs.h" | 14 | #include "debugfs.h" |
15 | #include "tracefs.h" | ||
15 | 16 | ||
16 | #ifndef DEBUGFS_DEFAULT_PATH | 17 | #ifndef DEBUGFS_DEFAULT_PATH |
17 | #define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug" | 18 | #define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug" |
@@ -94,11 +95,21 @@ int debugfs__strerror_open(int err, char *buf, size_t size, const char *filename | |||
94 | "Hint:\tIs the debugfs filesystem mounted?\n" | 95 | "Hint:\tIs the debugfs filesystem mounted?\n" |
95 | "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'"); | 96 | "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'"); |
96 | break; | 97 | break; |
97 | case EACCES: | 98 | case EACCES: { |
99 | const char *mountpoint = debugfs_mountpoint; | ||
100 | |||
101 | if (!access(debugfs_mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) { | ||
102 | const char *tracefs_mntpoint = tracefs_find_mountpoint(); | ||
103 | |||
104 | if (tracefs_mntpoint) | ||
105 | mountpoint = tracefs_mntpoint; | ||
106 | } | ||
107 | |||
98 | snprintf(buf, size, | 108 | snprintf(buf, size, |
99 | "Error:\tNo permissions to read %s/%s\n" | 109 | "Error:\tNo permissions to read %s/%s\n" |
100 | "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", | 110 | "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n", |
101 | debugfs_mountpoint, filename, debugfs_mountpoint); | 111 | debugfs_mountpoint, filename, mountpoint); |
112 | } | ||
102 | break; | 113 | break; |
103 | default: | 114 | default: |
104 | snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf))); | 115 | snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf))); |