1
2
3
4
5
6
7
8#include <linux/module.h>
9#include <linux/fs.h>
10#include <linux/debugfs.h>
11#include <linux/ftrace.h>
12
13#include "trace.h"
14
15
16enum {
17 TRACE_NOP_OPT_ACCEPT = 0x1,
18 TRACE_NOP_OPT_REFUSE = 0x2
19};
20
21
22static struct tracer_opt nop_opts[] = {
23
24 { TRACER_OPT(test_nop_accept, TRACE_NOP_OPT_ACCEPT) },
25
26 { TRACER_OPT(test_nop_refuse, TRACE_NOP_OPT_REFUSE) },
27 { }
28};
29
30static struct tracer_flags nop_flags = {
31
32 .val = 0,
33 .opts = nop_opts
34};
35
36static struct trace_array *ctx_trace;
37
38static void start_nop_trace(struct trace_array *tr)
39{
40
41}
42
43static void stop_nop_trace(struct trace_array *tr)
44{
45
46}
47
48static int nop_trace_init(struct trace_array *tr)
49{
50 ctx_trace = tr;
51 start_nop_trace(tr);
52 return 0;
53}
54
55static void nop_trace_reset(struct trace_array *tr)
56{
57 stop_nop_trace(tr);
58}
59
60
61
62
63
64
65static int nop_set_flag(u32 old_flags, u32 bit, int set)
66{
67
68
69
70
71 if (bit == TRACE_NOP_OPT_ACCEPT) {
72 printk(KERN_DEBUG "nop_test_accept flag set to %d: we accept."
73 " Now cat trace_options to see the result\n",
74 set);
75 return 0;
76 }
77
78 if (bit == TRACE_NOP_OPT_REFUSE) {
79 printk(KERN_DEBUG "nop_test_refuse flag set to %d: we refuse."
80 "Now cat trace_options to see the result\n",
81 set);
82 return -EINVAL;
83 }
84
85 return 0;
86}
87
88
89struct tracer nop_trace __read_mostly =
90{
91 .name = "nop",
92 .init = nop_trace_init,
93 .reset = nop_trace_reset,
94 .wait_pipe = poll_wait_pipe,
95#ifdef CONFIG_FTRACE_SELFTEST
96 .selftest = trace_selftest_startup_nop,
97#endif
98 .flags = &nop_flags,
99 .set_flag = nop_set_flag
100};
101
102