summaryrefslogtreecommitdiffstats
path: root/tools/lib/api
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-09-02 03:56:40 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-04 11:01:00 -0400
commitc495afb4988dcbb8bae11b8f1bbb7e11f172672b (patch)
tree4713244446ae1ce0ac9ad172bc0f10e6410ac370 /tools/lib/api
parent8ccfabdb873df2e18b235bfaf2722f7528d220f1 (diff)
tools lib api fs: Add tracefs into fs.c object
Adding tracefs support into fs.c framework. It'll replace the tracefs object functionality in following patches. Signed-off-by: Jiri Olsa <jolsa@kernel.org> Cc: Raphael Beamonte <raphael.beamonte@gmail.com> 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: Steven Rostedt <rostedt@goodmis.org> Link: http://lkml.kernel.org/r/1441180605-24737-11-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/api')
-rw-r--r--tools/lib/api/fs/fs.c28
-rw-r--r--tools/lib/api/fs/fs.h1
2 files changed, 29 insertions, 0 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 798052cbc7c0..ef16d2a83a27 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -28,6 +28,10 @@
28#define DEBUGFS_MAGIC 0x64626720 28#define DEBUGFS_MAGIC 0x64626720
29#endif 29#endif
30 30
31#ifndef TRACEFS_MAGIC
32#define TRACEFS_MAGIC 0x74726163
33#endif
34
31static const char * const sysfs__fs_known_mountpoints[] = { 35static const char * const sysfs__fs_known_mountpoints[] = {
32 "/sys", 36 "/sys",
33 0, 37 0,
@@ -48,6 +52,19 @@ static const char * const debugfs__known_mountpoints[] = {
48 0, 52 0,
49}; 53};
50 54
55
56#ifndef TRACEFS_DEFAULT_PATH
57#define TRACEFS_DEFAULT_PATH "/sys/kernel/tracing"
58#endif
59
60static const char * const tracefs__known_mountpoints[] = {
61 TRACEFS_DEFAULT_PATH,
62 "/sys/kernel/debug/tracing",
63 "/tracing",
64 "/trace",
65 0,
66};
67
51struct fs { 68struct fs {
52 const char *name; 69 const char *name;
53 const char * const *mounts; 70 const char * const *mounts;
@@ -60,8 +77,13 @@ enum {
60 FS__SYSFS = 0, 77 FS__SYSFS = 0,
61 FS__PROCFS = 1, 78 FS__PROCFS = 1,
62 FS__DEBUGFS = 2, 79 FS__DEBUGFS = 2,
80 FS__TRACEFS = 3,
63}; 81};
64 82
83#ifndef TRACEFS_MAGIC
84#define TRACEFS_MAGIC 0x74726163
85#endif
86
65static struct fs fs__entries[] = { 87static struct fs fs__entries[] = {
66 [FS__SYSFS] = { 88 [FS__SYSFS] = {
67 .name = "sysfs", 89 .name = "sysfs",
@@ -78,6 +100,11 @@ static struct fs fs__entries[] = {
78 .mounts = debugfs__known_mountpoints, 100 .mounts = debugfs__known_mountpoints,
79 .magic = DEBUGFS_MAGIC, 101 .magic = DEBUGFS_MAGIC,
80 }, 102 },
103 [FS__TRACEFS] = {
104 .name = "tracefs",
105 .mounts = tracefs__known_mountpoints,
106 .magic = TRACEFS_MAGIC,
107 },
81}; 108};
82 109
83static bool fs__read_mounts(struct fs *fs) 110static bool fs__read_mounts(struct fs *fs)
@@ -197,6 +224,7 @@ const char *name##__mountpoint(void) \
197FS__MOUNTPOINT(sysfs, FS__SYSFS); 224FS__MOUNTPOINT(sysfs, FS__SYSFS);
198FS__MOUNTPOINT(procfs, FS__PROCFS); 225FS__MOUNTPOINT(procfs, FS__PROCFS);
199FS__MOUNTPOINT(debugfs, FS__DEBUGFS); 226FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
227FS__MOUNTPOINT(tracefs, FS__TRACEFS);
200 228
201int filename__read_int(const char *filename, int *value) 229int filename__read_int(const char *filename, int *value)
202{ 230{
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index a4e6b1d93d2f..9013227ae0d1 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -12,6 +12,7 @@
12const char *sysfs__mountpoint(void); 12const char *sysfs__mountpoint(void);
13const char *procfs__mountpoint(void); 13const char *procfs__mountpoint(void);
14const char *debugfs__mountpoint(void); 14const char *debugfs__mountpoint(void);
15const char *tracefs__mountpoint(void);
15 16
16int filename__read_int(const char *filename, int *value); 17int filename__read_int(const char *filename, int *value);
17int sysctl__read_int(const char *sysctl, int *value); 18int sysctl__read_int(const char *sysctl, int *value);