Commit 8ccfabdb authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 41e3a1fe
/* TODO merge/factor in debugfs.c here */
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -26,6 +24,10 @@ ...@@ -26,6 +24,10 @@
#define PROC_SUPER_MAGIC 0x9fa0 #define PROC_SUPER_MAGIC 0x9fa0
#endif #endif
#ifndef DEBUGFS_MAGIC
#define DEBUGFS_MAGIC 0x64626720
#endif
static const char * const sysfs__fs_known_mountpoints[] = { static const char * const sysfs__fs_known_mountpoints[] = {
"/sys", "/sys",
0, 0,
...@@ -36,6 +38,16 @@ static const char * const procfs__known_mountpoints[] = { ...@@ -36,6 +38,16 @@ static const char * const procfs__known_mountpoints[] = {
0, 0,
}; };
#ifndef DEBUGFS_DEFAULT_PATH
#define DEBUGFS_DEFAULT_PATH "/sys/kernel/debug"
#endif
static const char * const debugfs__known_mountpoints[] = {
DEBUGFS_DEFAULT_PATH,
"/debug",
0,
};
struct fs { struct fs {
const char *name; const char *name;
const char * const *mounts; const char * const *mounts;
...@@ -45,8 +57,9 @@ struct fs { ...@@ -45,8 +57,9 @@ struct fs {
}; };
enum { enum {
FS__SYSFS = 0, FS__SYSFS = 0,
FS__PROCFS = 1, FS__PROCFS = 1,
FS__DEBUGFS = 2,
}; };
static struct fs fs__entries[] = { static struct fs fs__entries[] = {
...@@ -60,6 +73,11 @@ static struct fs fs__entries[] = { ...@@ -60,6 +73,11 @@ static struct fs fs__entries[] = {
.mounts = procfs__known_mountpoints, .mounts = procfs__known_mountpoints,
.magic = PROC_SUPER_MAGIC, .magic = PROC_SUPER_MAGIC,
}, },
[FS__DEBUGFS] = {
.name = "debugfs",
.mounts = debugfs__known_mountpoints,
.magic = DEBUGFS_MAGIC,
},
}; };
static bool fs__read_mounts(struct fs *fs) static bool fs__read_mounts(struct fs *fs)
...@@ -176,8 +194,9 @@ const char *name##__mountpoint(void) \ ...@@ -176,8 +194,9 @@ const char *name##__mountpoint(void) \
return fs__mountpoint(idx); \ return fs__mountpoint(idx); \
} }
FS__MOUNTPOINT(sysfs, FS__SYSFS); FS__MOUNTPOINT(sysfs, FS__SYSFS);
FS__MOUNTPOINT(procfs, FS__PROCFS); FS__MOUNTPOINT(procfs, FS__PROCFS);
FS__MOUNTPOINT(debugfs, FS__DEBUGFS);
int filename__read_int(const char *filename, int *value) int filename__read_int(const char *filename, int *value)
{ {
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
const char *sysfs__mountpoint(void); const char *sysfs__mountpoint(void);
const char *procfs__mountpoint(void); const char *procfs__mountpoint(void);
const char *debugfs__mountpoint(void);
int filename__read_int(const char *filename, int *value); int filename__read_int(const char *filename, int *value);
int sysctl__read_int(const char *sysctl, int *value); int sysctl__read_int(const char *sysctl, int *value);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment