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 <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Don Zickus <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Stephane Eranian <[email protected]>
Link: http://lkml.kernel.org/n/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>

 	tools/perf/util/include/asm/hash.h
This commit is contained in:
Arnaldo Carvalho de Melo 2015-01-22 10:34:22 -03:00
commit e2726d9964
5 changed files with 38 additions and 30 deletions

View file

@ -1,3 +1,4 @@
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
@ -98,3 +99,29 @@ char *debugfs_mount(const char *mountpoint)
out:
return debugfs_mountpoint;
}
int debugfs__strerror_open(int err, char *buf, size_t size)
{
char sbuf[128];
switch (err) {
case ENOENT:
snprintf(buf, size, "%s",
"Error:\tUnable to find debugfs\n"
"Hint:\tWas your kernel compiled with debugfs support?\n"
"Hint:\tIs the debugfs filesystem mounted?\n"
"Hint:\tTry 'sudo mount -t debugfs nodev /sys/kernel/debug'");
break;
case EACCES:
snprintf(buf, size,
"Error:\tNo permissions to read %s/tracing/events/raw_syscalls\n"
"Hint:\tTry 'sudo mount -o remount,mode=755 %s'\n",
debugfs_mountpoint, debugfs_mountpoint);
break;
default:
snprintf(buf, size, "%s", strerror_r(err, sbuf, sizeof(sbuf)));
break;
}
return 0;
}

View file

@ -26,4 +26,6 @@ char *debugfs_mount(const char *mountpoint);
extern char debugfs_mountpoint[];
int debugfs__strerror_open(int err, char *buf, size_t size);
#endif /* __API_DEBUGFS_H__ */