Commit 48966364 authored by jolsa@redhat.com's avatar jolsa@redhat.com Committed by Steven Rostedt

tracing: trace parser support for set_event

Convert the parsing of the file 'set_event' to use the generic
trace_praser 'trace_get_user' function.
Signed-off-by: default avatarJiri Olsa <jolsa@redhat.com>
LKML-Reference: <1252682969-3366-3-git-send-email-jolsa@redhat.com>
Signed-off-by: default avatarSteven Rostedt <rostedt@goodmis.org>
parent b63f39ea
...@@ -230,11 +230,9 @@ static ssize_t ...@@ -230,11 +230,9 @@ static ssize_t
ftrace_event_write(struct file *file, const char __user *ubuf, ftrace_event_write(struct file *file, const char __user *ubuf,
size_t cnt, loff_t *ppos) size_t cnt, loff_t *ppos)
{ {
struct trace_parser parser;
size_t read = 0; size_t read = 0;
int i, set = 1;
ssize_t ret; ssize_t ret;
char *buf;
char ch;
if (!cnt || cnt < 0) if (!cnt || cnt < 0)
return 0; return 0;
...@@ -243,60 +241,28 @@ ftrace_event_write(struct file *file, const char __user *ubuf, ...@@ -243,60 +241,28 @@ ftrace_event_write(struct file *file, const char __user *ubuf,
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = get_user(ch, ubuf++); if (trace_parser_get_init(&parser, EVENT_BUF_SIZE + 1))
if (ret)
return ret;
read++;
cnt--;
/* skip white space */
while (cnt && isspace(ch)) {
ret = get_user(ch, ubuf++);
if (ret)
return ret;
read++;
cnt--;
}
/* Only white space found? */
if (isspace(ch)) {
file->f_pos += read;
ret = read;
return ret;
}
buf = kmalloc(EVENT_BUF_SIZE+1, GFP_KERNEL);
if (!buf)
return -ENOMEM; return -ENOMEM;
if (cnt > EVENT_BUF_SIZE) read = trace_get_user(&parser, ubuf, cnt, ppos);
cnt = EVENT_BUF_SIZE;
i = 0; if (trace_parser_loaded((&parser))) {
while (cnt && !isspace(ch)) { int set = 1;
if (!i && ch == '!')
set = 0;
else
buf[i++] = ch;
ret = get_user(ch, ubuf++); if (*parser.buffer == '!')
if (ret) set = 0;
goto out_free;
read++;
cnt--;
}
buf[i] = 0;
file->f_pos += read; parser.buffer[parser.idx] = 0;
ret = ftrace_set_clr_event(buf, set); ret = ftrace_set_clr_event(parser.buffer + !set, set);
if (ret) if (ret)
goto out_free; goto out_put;
}
ret = read; ret = read;
out_free: out_put:
kfree(buf); trace_parser_put(&parser);
return ret; return ret;
} }
......
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