diff options
author | Joe Stringer <joe@ovn.org> | 2017-01-26 16:20:00 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2017-01-31 14:20:07 -0500 |
commit | 71dc4c30680fa7e7fd4b82352a845e2fb4d86b2b (patch) | |
tree | 67f878a70fca8daab3a6d16303dccdc752904ddf | |
parent | 9a9c733d68c5cb89bd5c5ab91b9821e1a5d69272 (diff) |
tools lib api fs: Add bpf_fs filesystem detector
Allow mounting of the BPF filesystem at /sys/fs/bpf.
Signed-off-by: Joe Stringer <joe@ovn.org>
Cc: Alexei Starovoitov <ast@fb.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Wang Nan <wangnan0@huawei.com>
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/20170126212001.14103-6-joe@ovn.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/lib/api/fs/fs.c | 16 | ||||
-rw-r--r-- | tools/lib/api/fs/fs.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/tools/lib/api/fs/fs.c b/tools/lib/api/fs/fs.c index f99f49e4a31e..4b6bfc43cccf 100644 --- a/tools/lib/api/fs/fs.c +++ b/tools/lib/api/fs/fs.c | |||
@@ -38,6 +38,10 @@ | |||
38 | #define HUGETLBFS_MAGIC 0x958458f6 | 38 | #define HUGETLBFS_MAGIC 0x958458f6 |
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #ifndef BPF_FS_MAGIC | ||
42 | #define BPF_FS_MAGIC 0xcafe4a11 | ||
43 | #endif | ||
44 | |||
41 | static const char * const sysfs__fs_known_mountpoints[] = { | 45 | static const char * const sysfs__fs_known_mountpoints[] = { |
42 | "/sys", | 46 | "/sys", |
43 | 0, | 47 | 0, |
@@ -75,6 +79,11 @@ static const char * const hugetlbfs__known_mountpoints[] = { | |||
75 | 0, | 79 | 0, |
76 | }; | 80 | }; |
77 | 81 | ||
82 | static const char * const bpf_fs__known_mountpoints[] = { | ||
83 | "/sys/fs/bpf", | ||
84 | 0, | ||
85 | }; | ||
86 | |||
78 | struct fs { | 87 | struct fs { |
79 | const char *name; | 88 | const char *name; |
80 | const char * const *mounts; | 89 | const char * const *mounts; |
@@ -89,6 +98,7 @@ enum { | |||
89 | FS__DEBUGFS = 2, | 98 | FS__DEBUGFS = 2, |
90 | FS__TRACEFS = 3, | 99 | FS__TRACEFS = 3, |
91 | FS__HUGETLBFS = 4, | 100 | FS__HUGETLBFS = 4, |
101 | FS__BPF_FS = 5, | ||
92 | }; | 102 | }; |
93 | 103 | ||
94 | #ifndef TRACEFS_MAGIC | 104 | #ifndef TRACEFS_MAGIC |
@@ -121,6 +131,11 @@ static struct fs fs__entries[] = { | |||
121 | .mounts = hugetlbfs__known_mountpoints, | 131 | .mounts = hugetlbfs__known_mountpoints, |
122 | .magic = HUGETLBFS_MAGIC, | 132 | .magic = HUGETLBFS_MAGIC, |
123 | }, | 133 | }, |
134 | [FS__BPF_FS] = { | ||
135 | .name = "bpf", | ||
136 | .mounts = bpf_fs__known_mountpoints, | ||
137 | .magic = BPF_FS_MAGIC, | ||
138 | }, | ||
124 | }; | 139 | }; |
125 | 140 | ||
126 | static bool fs__read_mounts(struct fs *fs) | 141 | static bool fs__read_mounts(struct fs *fs) |
@@ -280,6 +295,7 @@ FS(procfs, FS__PROCFS); | |||
280 | FS(debugfs, FS__DEBUGFS); | 295 | FS(debugfs, FS__DEBUGFS); |
281 | FS(tracefs, FS__TRACEFS); | 296 | FS(tracefs, FS__TRACEFS); |
282 | FS(hugetlbfs, FS__HUGETLBFS); | 297 | FS(hugetlbfs, FS__HUGETLBFS); |
298 | FS(bpf_fs, FS__BPF_FS); | ||
283 | 299 | ||
284 | int filename__read_int(const char *filename, int *value) | 300 | int filename__read_int(const char *filename, int *value) |
285 | { | 301 | { |
diff --git a/tools/lib/api/fs/fs.h b/tools/lib/api/fs/fs.h index a63269f5d20c..6b332dc74498 100644 --- a/tools/lib/api/fs/fs.h +++ b/tools/lib/api/fs/fs.h | |||
@@ -22,6 +22,7 @@ FS(procfs) | |||
22 | FS(debugfs) | 22 | FS(debugfs) |
23 | FS(tracefs) | 23 | FS(tracefs) |
24 | FS(hugetlbfs) | 24 | FS(hugetlbfs) |
25 | FS(bpf_fs) | ||
25 | 26 | ||
26 | #undef FS | 27 | #undef FS |
27 | 28 | ||