tracing: create generic trace parser
Create a "trace_parser" that can parse the user space input for separate words. struct trace_parser is the descriptor. Generic "trace_get_user" function that can be a helper to read multiple words passed in by user space. Signed-off-by: Jiri Olsa <jolsa@redhat.com> LKML-Reference: <1252682969-3366-2-git-send-email-jolsa@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
This commit is contained in:
committed by
Steven Rostedt
parent
f81c972d27
commit
b63f39ea50
@@ -615,6 +615,41 @@ static inline int ftrace_trace_task(struct task_struct *task)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* struct trace_parser - servers for reading the user input separated by spaces
|
||||
* @cont: set if the input is not complete - no final space char was found
|
||||
* @buffer: holds the parsed user input
|
||||
* @idx: user input lenght
|
||||
* @size: buffer size
|
||||
*/
|
||||
struct trace_parser {
|
||||
bool cont;
|
||||
char *buffer;
|
||||
unsigned idx;
|
||||
unsigned size;
|
||||
};
|
||||
|
||||
static inline bool trace_parser_loaded(struct trace_parser *parser)
|
||||
{
|
||||
return (parser->idx != 0);
|
||||
}
|
||||
|
||||
static inline bool trace_parser_cont(struct trace_parser *parser)
|
||||
{
|
||||
return parser->cont;
|
||||
}
|
||||
|
||||
static inline void trace_parser_clear(struct trace_parser *parser)
|
||||
{
|
||||
parser->cont = false;
|
||||
parser->idx = 0;
|
||||
}
|
||||
|
||||
extern int trace_parser_get_init(struct trace_parser *parser, int size);
|
||||
extern void trace_parser_put(struct trace_parser *parser);
|
||||
extern int trace_get_user(struct trace_parser *parser, const char __user *ubuf,
|
||||
size_t cnt, loff_t *ppos);
|
||||
|
||||
/*
|
||||
* trace_iterator_flags is an enumeration that defines bit
|
||||
* positions into trace_flags that controls the output.
|
||||
|
Reference in New Issue
Block a user