Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools lib api fs: Add {tracefs,debugfs}_configured() functions

Add tracefs_configured() to return true if tracefs is configured in the
kernel (succeeds to find tracefs), and debugfs_configured() if debugfs
is configured in the kernel (succeeds to find debugfs).

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150202193553.190606690@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Steven Rostedt (Red Hat) and committed by
Arnaldo Carvalho de Melo
dd6dda27 a9edf607

+20
+8
tools/lib/api/fs/debugfs.c
··· 3 3 #include <stdio.h> 4 4 #include <stdlib.h> 5 5 #include <string.h> 6 + #include <unistd.h> 6 7 #include <stdbool.h> 7 8 #include <sys/vfs.h> 9 + #include <sys/types.h> 10 + #include <sys/stat.h> 8 11 #include <sys/mount.h> 9 12 #include <linux/kernel.h> 10 13 ··· 26 23 }; 27 24 28 25 static bool debugfs_found; 26 + 27 + bool debugfs_configured(void) 28 + { 29 + return debugfs_find_mountpoint() != NULL; 30 + } 29 31 30 32 /* find the path to the mounted debugfs */ 31 33 const char *debugfs_find_mountpoint(void)
+1
tools/lib/api/fs/debugfs.h
··· 11 11 #define PERF_DEBUGFS_ENVIRONMENT "PERF_DEBUGFS_DIR" 12 12 #endif 13 13 14 + bool debugfs_configured(void); 14 15 const char *debugfs_find_mountpoint(void); 15 16 char *debugfs_mount(const char *mountpoint); 16 17
+2
tools/lib/api/fs/findfs.h
··· 1 1 #ifndef __API_FINDFS_H__ 2 2 #define __API_FINDFS_H__ 3 3 4 + #include <stdbool.h> 5 + 4 6 #define _STR(x) #x 5 7 #define STR(x) _STR(x) 6 8
+8
tools/lib/api/fs/tracefs.c
··· 2 2 #include <stdio.h> 3 3 #include <stdlib.h> 4 4 #include <string.h> 5 + #include <unistd.h> 5 6 #include <stdbool.h> 6 7 #include <sys/vfs.h> 8 + #include <sys/types.h> 9 + #include <sys/stat.h> 7 10 #include <sys/mount.h> 8 11 #include <linux/kernel.h> 9 12 ··· 27 24 }; 28 25 29 26 static bool tracefs_found; 27 + 28 + bool tracefs_configured(void) 29 + { 30 + return tracefs_find_mountpoint() != NULL; 31 + } 30 32 31 33 /* find the path to the mounted tracefs */ 32 34 const char *tracefs_find_mountpoint(void)
+1
tools/lib/api/fs/tracefs.h
··· 11 11 #define PERF_TRACEFS_ENVIRONMENT "PERF_TRACEFS_DIR" 12 12 #endif 13 13 14 + bool tracefs_configured(void); 14 15 const char *tracefs_find_mountpoint(void); 15 16 int tracefs_valid_mountpoint(const char *debugfs); 16 17 char *tracefs_mount(const char *mountpoint);