tools lib api fs: Store tracing mountpoint for better error message
PATCH 1/1 tools lib api fs: Store tracing mountpoint for better error message
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'
...
--- tools/lib/api/fs/tracing_path.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +3 -10
@@ -12,12 +12,14 @@#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 :
Signature · 1 line
2.4.3
tools/lib/api/fs/tracing_path.c line 17
Quoted 11 lines · Jiri Olsa
tools/lib/api/fs/tracing_path.c +1
-0@@ -12,12 +12,14 @@#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" ;
why all the +1s? null terminator has to fit within PATH_MAX as well.
Quoted 20 lines
tools/lib/api/fs/tracing_path.c +1
-7static 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 ();
tools/lib/api/fs/tracing_path.c static int strerror_open(int err, char *buf, size_t size, const char *filename) · line 120
Quoted 10 lines
tools/lib/api/fs/tracing_path.c +1
-3- } -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 :
LGTM.
David
Quoted 10 lines · David Ahern
Quoted 8 lines · Jiri Olsa
tools/lib/api/fs/tracing_path.c +0
-0@@ -12,12 +12,14 @@#include "tracing_path.h"
Quoted 5 lines
tools/lib/api/fs/tracing_path.c line 17
Quoted 3 lines
tools/lib/api/fs/tracing_path.c +1
-0+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" ;why all the +1s? null terminator has to fit within
PATH_MAXas well.
good question.. can't see a reason ATM
jirka
Quoted 35 lines
Quoted 21 lines
tools/lib/api/fs/tracing_path.c +1
-7static 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 ();tools/lib/api/fs/tracing_path.c static int strerror_open(int err, char *buf, size_t size, const char *filename) · line 120
Quoted 10 lines
tools/lib/api/fs/tracing_path.c +1
-3- } -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 :LGTM.
David
2015-09-19 11:00 GMT-04:00 Jiri Olsa <[email protected]>:
Quoted 11 lines · David Ahern
Quoted 10 lines · Jiri Olsa
Quoted 9 lines
tools/lib/api/fs/tracing_path.c +0
-0@@ -12,12 +12,14 @@#include "tracing_path.h"
Quoted 7 lines
Quoted 5 lines
tools/lib/api/fs/tracing_path.c line 17
Quoted 3 lines
tools/lib/api/fs/tracing_path.c +1
-0+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" ;why all the +1s? null terminator has to fit within
PATH_MAXas well.good question.. can't see a reason ATM
It is quite weird actually, it seems there is multiple occurrences of that, without any comment to explain why that +1, even if the #define of PATH_MAX in limits.h specify that that size also counts nul. Most of these occurrences are linked to perf though, but there's also fs/ocfs2/aops.c, scripts/docproc.c and usr/gen_init_cpio.c. Perhaps a mistake that started somewhere and that was propagated looking at the original mistake?
Quoted 37 lines
jirka
Quoted 35 lines
Quoted 21 lines
tools/lib/api/fs/tracing_path.c +1
-7static 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 ();tools/lib/api/fs/tracing_path.c static int strerror_open(int err, char *buf, size_t size, const char *filename) · line 120
Quoted 10 lines
tools/lib/api/fs/tracing_path.c +1
-3- } -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 :LGTM.
David
2015-09-19 10:47 GMT-04:00 Jiri Olsa <[email protected]>:
Quoted 70 lines
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 eventsError: 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 eventsError: 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 <[email protected]>--- tools/lib/api/fs/tracing_path.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)tools/lib/api/fs/tracing_path.c +3
-11@@ -12,12 +12,14 @@#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 : --
Quoted 2 lines
2.4.3
tip-bot for Jiri Olsa
merge bottools lib api fs: Store tracing mountpoint for better error message
Commit-ID: dc240c5dc2a02e335c5bcb50ad3a1274818c8609 Gitweb: http://git.kernel.org/tip/dc240c5dc2a02e335c5bcb50ad3a1274818c8609 Author: Jiri Olsa <[email protected]> AuthorDate: Sat, 19 Sep 2015 16:47:07 +0200 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Mon, 28 Sep 2015 15:50:54 -0300
tools lib api fs: Store tracing mountpoint for better error message
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'
...
--- tools/lib/api/fs/tracing_path.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-)
tools/lib/api/fs/tracing_path.c +3 -10
@@ -12,12 +12,14 @@#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 :