tools lib api fs: Store tracing mountpoint for better error message
authorJiri Olsa <jolsa@kernel.org>
Sat, 19 Sep 2015 14:47:07 +0000 (16:47 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 28 Sep 2015 18:50:54 +0000 (15:50 -0300)
Storing the actual tracing path mountpoint to display correct
error message hint ('Hint:' line). The error hint rediscovers
mountpoints, but it could be different from what we actually
used in tracing path.

Before we'd display debugfs mount even though tracefs was used:
  $ perf record -e sched:sched_krava ls
  event syntax error: 'sched:sched_krava'
                       \___ can't access trace events

  Error:  No permissions to read /sys/kernel/debug/tracing/events/sched/sched_krava
  Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug'
  ...

After this change, correct mountpoint is displayed:
  $ perf record -e sched:sched_krava ls
  event syntax error: 'sched:sched_krava'
                       \___ can't access trace events

  Error:  No permissions to read /sys/kernel/debug/tracing/events/sched/sched_krava
  Hint:   Try 'sudo mount -o remount,mode=755 /sys/kernel/debug/tracing'
  ...

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Raphael Beamonte <raphael.beamonte@gmail.com>
Link: http://lkml.kernel.org/r/1442674027-19427-1-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/api/fs/tracing_path.c

index 38aca2dd19461a9bea909a27f77b95874b846fef..0406a7d5c891c4f1c6df4c0cf1c1f874164c32a5 100644 (file)
 #include "tracing_path.h"
 
 
+char tracing_mnt[PATH_MAX + 1]         = "/sys/kernel/debug";
 char tracing_path[PATH_MAX + 1]        = "/sys/kernel/debug/tracing";
 char tracing_events_path[PATH_MAX + 1] = "/sys/kernel/debug/tracing/events";
 
 
 static void __tracing_path_set(const char *tracing, const char *mountpoint)
 {
+       snprintf(tracing_mnt, sizeof(tracing_mnt), "%s", mountpoint);
        snprintf(tracing_path, sizeof(tracing_path), "%s/%s",
                 mountpoint, tracing);
        snprintf(tracing_events_path, sizeof(tracing_events_path), "%s/%s%s",
@@ -109,19 +111,10 @@ static int strerror_open(int err, char *buf, size_t size, const char *filename)
                         "Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
                break;
        case EACCES: {
-               const char *mountpoint = debugfs__mountpoint();
-
-               if (!access(mountpoint, R_OK) && strncmp(filename, "tracing/", 8) == 0) {
-                       const char *tracefs_mntpoint = tracefs__mountpoint();
-
-                       if (tracefs_mntpoint)
-                               mountpoint = tracefs__mountpoint();
-               }
-
                snprintf(buf, size,
                         "Error:\tNo permissions to read %s/%s\n"
                         "Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
-                        tracing_events_path, filename, mountpoint);
+                        tracing_events_path, filename, tracing_mnt);
        }
                break;
        default: