From: "Steven Rostedt (Red Hat)" Add tracefs_configured() to return true if tracefs is configured in the kernel (/sys/kernel/tracing exists), and debugfs_configured() if debugfs is configured in the kernel (/sys/kernel/debug exists). Signed-off-by: Steven Rostedt --- tools/lib/api/fs/debugfs.c | 13 +++++++++++++ tools/lib/api/fs/debugfs.h | 1 + tools/lib/api/fs/tracefs.c | 13 +++++++++++++ tools/lib/api/fs/tracefs.h | 1 + 4 files changed, 28 insertions(+) diff --git a/tools/lib/api/fs/debugfs.c b/tools/lib/api/fs/debugfs.c index 1637e5b6a5d5..a2d8e59f042b 100644 --- a/tools/lib/api/fs/debugfs.c +++ b/tools/lib/api/fs/debugfs.c @@ -2,8 +2,11 @@ #include #include #include +#include #include #include +#include +#include #include #include @@ -24,6 +27,16 @@ static const char * const debugfs_known_mountpoints[] = { static bool debugfs_found; +bool debugfs_configured(void) +{ + struct stat st; + + if (stat(DEBUGFS_DEFAULT_PATH, &st) < 0) + return false; + + return true; +} + /* find the path to the mounted debugfs */ const char *debugfs_find_mountpoint(void) { diff --git a/tools/lib/api/fs/debugfs.h b/tools/lib/api/fs/debugfs.h index f19d3df9609d..a8a385008db3 100644 --- a/tools/lib/api/fs/debugfs.h +++ b/tools/lib/api/fs/debugfs.h @@ -20,6 +20,7 @@ #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" #endif +bool debugfs_configured(void); const char *debugfs_find_mountpoint(void); int debugfs_valid_mountpoint(const char *debugfs); char *debugfs_mount(const char *mountpoint); diff --git a/tools/lib/api/fs/tracefs.c b/tools/lib/api/fs/tracefs.c index bdaf54142c5d..43cb0b24a999 100644 --- a/tools/lib/api/fs/tracefs.c +++ b/tools/lib/api/fs/tracefs.c @@ -2,8 +2,11 @@ #include #include #include +#include #include #include +#include +#include #include #include @@ -26,6 +29,16 @@ static const char * const tracefs_known_mountpoints[] = { static bool tracefs_found; +bool tracefs_configured(void) +{ + struct stat st; + + if (stat(TRACEFS_DEFAULT_PATH, &st) < 0) + return false; + + return true; +} + /* find the path to the mounted tracefs */ const char *tracefs_find_mountpoint(void) { diff --git a/tools/lib/api/fs/tracefs.h b/tools/lib/api/fs/tracefs.h index 576206500e15..a25a003a9ee6 100644 --- a/tools/lib/api/fs/tracefs.h +++ b/tools/lib/api/fs/tracefs.h @@ -20,6 +20,7 @@ #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" #endif +bool tracefs_configured(void); const char *tracefs_find_mountpoint(void); int tracefs_valid_mountpoint(const char *debugfs); char *tracefs_mount(const char *mountpoint); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/