Skip to content

Commit 15075ca

Browse files
Steven Rostedtrostedt
authored andcommitted
tracing: Separate open function from set_event and available_events
The open function used by available_events is the same as set_event even though it uses different seq functions. This causes a side effect of writing into available_events clearing all events, even though available_events is suppose to be read only. There's no reason to keep a single function for just the open and have both use different functions for everything else. It is a little confusing and causes strange behavior. Just have each have their own function. Signed-off-by: Steven Rostedt <[email protected]>
1 parent 50ecf2c commit 15075ca

File tree

1 file changed

+27
-19
lines changed

1 file changed

+27
-19
lines changed

kernel/trace/trace_events.c

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -491,19 +491,6 @@ static void t_stop(struct seq_file *m, void *p)
491491
mutex_unlock(&event_mutex);
492492
}
493493

494-
static int
495-
ftrace_event_seq_open(struct inode *inode, struct file *file)
496-
{
497-
const struct seq_operations *seq_ops;
498-
499-
if ((file->f_mode & FMODE_WRITE) &&
500-
(file->f_flags & O_TRUNC))
501-
ftrace_clear_events();
502-
503-
seq_ops = inode->i_private;
504-
return seq_open(file, seq_ops);
505-
}
506-
507494
static ssize_t
508495
event_enable_read(struct file *filp, char __user *ubuf, size_t cnt,
509496
loff_t *ppos)
@@ -980,6 +967,9 @@ show_header(struct file *filp, char __user *ubuf, size_t cnt, loff_t *ppos)
980967
return r;
981968
}
982969

970+
static int ftrace_event_avail_open(struct inode *inode, struct file *file);
971+
static int ftrace_event_set_open(struct inode *inode, struct file *file);
972+
983973
static const struct seq_operations show_event_seq_ops = {
984974
.start = t_start,
985975
.next = t_next,
@@ -995,14 +985,14 @@ static const struct seq_operations show_set_event_seq_ops = {
995985
};
996986

997987
static const struct file_operations ftrace_avail_fops = {
998-
.open = ftrace_event_seq_open,
988+
.open = ftrace_event_avail_open,
999989
.read = seq_read,
1000990
.llseek = seq_lseek,
1001991
.release = seq_release,
1002992
};
1003993

1004994
static const struct file_operations ftrace_set_event_fops = {
1005-
.open = ftrace_event_seq_open,
995+
.open = ftrace_event_set_open,
1006996
.read = seq_read,
1007997
.write = ftrace_event_write,
1008998
.llseek = seq_lseek,
@@ -1078,6 +1068,26 @@ static struct dentry *event_trace_events_dir(void)
10781068
return d_events;
10791069
}
10801070

1071+
static int
1072+
ftrace_event_avail_open(struct inode *inode, struct file *file)
1073+
{
1074+
const struct seq_operations *seq_ops = &show_event_seq_ops;
1075+
1076+
return seq_open(file, seq_ops);
1077+
}
1078+
1079+
static int
1080+
ftrace_event_set_open(struct inode *inode, struct file *file)
1081+
{
1082+
const struct seq_operations *seq_ops = &show_set_event_seq_ops;
1083+
1084+
if ((file->f_mode & FMODE_WRITE) &&
1085+
(file->f_flags & O_TRUNC))
1086+
ftrace_clear_events();
1087+
1088+
return seq_open(file, seq_ops);
1089+
}
1090+
10811091
static struct dentry *
10821092
event_subsystem_dir(const char *name, struct dentry *d_events)
10831093
{
@@ -1508,15 +1518,13 @@ static __init int event_trace_init(void)
15081518
return 0;
15091519

15101520
entry = debugfs_create_file("available_events", 0444, d_tracer,
1511-
(void *)&show_event_seq_ops,
1512-
&ftrace_avail_fops);
1521+
NULL, &ftrace_avail_fops);
15131522
if (!entry)
15141523
pr_warning("Could not create debugfs "
15151524
"'available_events' entry\n");
15161525

15171526
entry = debugfs_create_file("set_event", 0644, d_tracer,
1518-
(void *)&show_set_event_seq_ops,
1519-
&ftrace_set_event_fops);
1527+
NULL, &ftrace_set_event_fops);
15201528
if (!entry)
15211529
pr_warning("Could not create debugfs "
15221530
"'set_event' entry\n");

0 commit comments

Comments
 (0)