aboutsummaryrefslogtreecommitdiffstats
path: root/tools/lib/api/fs
diff options
context:
space:
mode:
authorJiri Olsa <jolsa@kernel.org>2015-09-02 03:56:39 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-04 11:00:59 -0400
commit8ccfabdb873df2e18b235bfaf2722f7528d220f1 (patch)
treebc6fe0e6a5282dd499e9fade7fe5425a8586d3fe /tools/lib/api/fs
parent41e3a1fece31d0b2383281e4a917ff4b16fa9223 (diff)
tools lib api fs: Add debugfs into fs.c object
Adding debugfs support into fs.c framework. It'll replace the debugfs 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-10-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/lib/api/fs')
-rw-r--r--tools/lib/api/fs/fs.c31
-rw-r--r--tools/lib/api/fs/fs.h1
2 files changed, 26 insertions, 6 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c
index 0700eb953495..798052cbc7c0 100644
--- a/tools/lib/api/fs/fs.c
+++ b/tools/lib/api/fs/fs.c
@@ -1,5 +1,3 @@
1/* TODO merge/factor in debugfs.c here */
2
3#include <ctype.h> 1#include <ctype.h>
4#include <errno.h> 2#include <errno.h>
5#include <stdbool.h> 3#include <stdbool.h>
@@ -26,6 +24,10 @@
26#define PROC_SUPER_MAGIC 0x9fa0 24#define PROC_SUPER_MAGIC 0x9fa0
27#endif 25#endif
28 26
27#ifndef DEBUGFS_MAGIC
28#define DEBUGFS_MAGIC 0x64626720
29#endif
30
29static const char * const sysfs__fs_known_mountpoints[] = { 31static const char * const sysfs__fs_known_mountpoints[] = {
30 "/sys", 32 "/sys",
31 0, 33 0,
@@ -36,6 +38,16 @@ static const char * const procfs__known_mountpoints[] = {
36 0, 38 0,
37}; 39};
38 40
41#ifndef DEBUGFS_DEFAULT_PATH
42#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug"
43#endif
44
45static const char * const debugfs__known_mountpoints[] = {
46 DEBUGFS_DEFAULT_PATH,
47 "/debug",
48 0,
49};
50
39struct fs { 51struct fs {
40 const char *name; 52 const char *name;
41 const char * const *mounts; 53 const char * const *mounts;
@@ -45,8 +57,9 @@ struct fs {
45}; 57};
46 58
47enum { 59enum {
48 FS__SYSFS = 0, 60 FS__SYSFS = 0,
49 FS__PROCFS = 1, 61 FS__PROCFS = 1,
62 FS__DEBUGFS = 2,
50}; 63};
51 64
52static struct fs fs__entries[] = { 65static struct fs fs__entries[] = {
@@ -60,6 +73,11 @@ static struct fs fs__entries[] = {
60 .mounts = procfs__known_mountpoints, 73 .mounts = procfs__known_mountpoints,
61 .magic = PROC_SUPER_MAGIC, 74 .magic = PROC_SUPER_MAGIC,
62 }, 75 },
76 [FS__DEBUGFS] = {
77 .name = "debugfs",
78 .mounts = debugfs__known_mountpoints,
79 .magic = DEBUGFS_MAGIC,
80 },
63}; 81};
64 82
65static bool fs__read_mounts(struct fs *fs) 83static bool fs__read_mounts(struct fs *fs)
@@ -176,8 +194,9 @@ const char *name##__mountpoint(void) \
176 return fs__mountpoint(idx); \ 194 return fs__mountpoint(idx); \
177} 195}
178 196
179FS__MOUNTPOINT(sysfs, FS__SYSFS); 197FS__MOUNTPOINT(sysfs, FS__SYSFS);
180FS__MOUNTPOINT(procfs, FS__PROCFS); 198FS__MOUNTPOINT(procfs, FS__PROCFS);
199FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
181 200
182int filename__read_int(const char *filename, int *value) 201int filename__read_int(const char *filename, int *value)
183{ 202{
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h
index 674efc8dfd9b..a4e6b1d93d2f 100644
--- a/tools/lib/api/fs/fs.h
+++ b/tools/lib/api/fs/fs.h
@@ -11,6 +11,7 @@
11 11
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);
14 15
15int filename__read_int(const char *filename, int *value); 16int filename__read_int(const char *filename, int *value);
16int sysctl__read_int(const char *sysctl, int *value); 17int sysctl__read_int(const char *sysctl, int *value);