aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/trace/ftrace.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/trace/ftrace.c')
-rw-r--r--kernel/trace/ftrace.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 4521c77d1a1a..25edd5cc5935 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -1662,7 +1662,7 @@ ftrace_regex_open(struct inode *inode, struct file *file, int enable)
1662 1662
1663 mutex_lock(&ftrace_regex_lock); 1663 mutex_lock(&ftrace_regex_lock);
1664 if ((file->f_mode & FMODE_WRITE) && 1664 if ((file->f_mode & FMODE_WRITE) &&
1665 !(file->f_flags & O_APPEND)) 1665 (file->f_flags & O_TRUNC))
1666 ftrace_filter_reset(enable); 1666 ftrace_filter_reset(enable);
1667 1667
1668 if (file->f_mode & FMODE_READ) { 1668 if (file->f_mode & FMODE_READ) {
@@ -2278,7 +2278,11 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2278 read++; 2278 read++;
2279 cnt--; 2279 cnt--;
2280 2280
2281 if (!(iter->flags & ~FTRACE_ITER_CONT)) { 2281 /*
2282 * If the parser haven't finished with the last write,
2283 * continue reading the user input without skipping spaces.
2284 */
2285 if (!(iter->flags & FTRACE_ITER_CONT)) {
2282 /* skip white space */ 2286 /* skip white space */
2283 while (cnt && isspace(ch)) { 2287 while (cnt && isspace(ch)) {
2284 ret = get_user(ch, ubuf++); 2288 ret = get_user(ch, ubuf++);
@@ -2288,8 +2292,9 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2288 cnt--; 2292 cnt--;
2289 } 2293 }
2290 2294
2295 /* only spaces were written */
2291 if (isspace(ch)) { 2296 if (isspace(ch)) {
2292 file->f_pos += read; 2297 *ppos += read;
2293 ret = read; 2298 ret = read;
2294 goto out; 2299 goto out;
2295 } 2300 }
@@ -2319,12 +2324,12 @@ ftrace_regex_write(struct file *file, const char __user *ubuf,
2319 if (ret) 2324 if (ret)
2320 goto out; 2325 goto out;
2321 iter->buffer_idx = 0; 2326 iter->buffer_idx = 0;
2322 } else 2327 } else {
2323 iter->flags |= FTRACE_ITER_CONT; 2328 iter->flags |= FTRACE_ITER_CONT;
2329 iter->buffer[iter->buffer_idx++] = ch;
2330 }
2324 2331
2325 2332 *ppos += read;
2326 file->f_pos += read;
2327
2328 ret = read; 2333 ret = read;
2329 out: 2334 out:
2330 mutex_unlock(&ftrace_regex_lock); 2335 mutex_unlock(&ftrace_regex_lock);
@@ -2577,7 +2582,7 @@ ftrace_graph_open(struct inode *inode, struct file *file)
2577 2582
2578 mutex_lock(&graph_lock); 2583 mutex_lock(&graph_lock);
2579 if ((file->f_mode & FMODE_WRITE) && 2584 if ((file->f_mode & FMODE_WRITE) &&
2580 !(file->f_flags & O_APPEND)) { 2585 (file->f_flags & O_TRUNC)) {
2581 ftrace_graph_count = 0; 2586 ftrace_graph_count = 0;
2582 memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs)); 2587 memset(ftrace_graph_funcs, 0, sizeof(ftrace_graph_funcs));
2583 } 2588 }
@@ -2596,6 +2601,14 @@ ftrace_graph_open(struct inode *inode, struct file *file)
2596} 2601}
2597 2602
2598static int 2603static int
2604ftrace_graph_release(struct inode *inode, struct file *file)
2605{
2606 if (file->f_mode & FMODE_READ)
2607 seq_release(inode, file);
2608 return 0;
2609}
2610
2611static int
2599ftrace_set_func(unsigned long *array, int *idx, char *buffer) 2612ftrace_set_func(unsigned long *array, int *idx, char *buffer)
2600{ 2613{
2601 struct dyn_ftrace *rec; 2614 struct dyn_ftrace *rec;
@@ -2724,9 +2737,10 @@ ftrace_graph_write(struct file *file, const char __user *ubuf,
2724} 2737}
2725 2738
2726static const struct file_operations ftrace_graph_fops = { 2739static const struct file_operations ftrace_graph_fops = {
2727 .open = ftrace_graph_open, 2740 .open = ftrace_graph_open,
2728 .read = seq_read, 2741 .read = seq_read,
2729 .write = ftrace_graph_write, 2742 .write = ftrace_graph_write,
2743 .release = ftrace_graph_release,
2730}; 2744};
2731#endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 2745#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
2732 2746