call->enabled = 0;
call->unregfunc();
}
- if (call->raw_enabled) {
- call->raw_enabled = 0;
- call->raw_unreg();
- }
break;
case 1:
- if (!call->enabled &&
- (call->type & TRACE_EVENT_TYPE_PRINTF)) {
+ if (!call->enabled) {
call->enabled = 1;
call->regfunc();
}
- if (!call->raw_enabled &&
- (call->type & TRACE_EVENT_TYPE_RAW)) {
- call->raw_enabled = 1;
- call->raw_reg();
- }
break;
}
}
struct ftrace_event_call *call = filp->private_data;
char *buf;
- if (call->enabled || call->raw_enabled)
+ if (call->enabled)
buf = "1\n";
else
buf = "0\n";
return cnt;
}
-static ssize_t
-event_type_read(struct file *filp, char __user *ubuf, size_t cnt,
- loff_t *ppos)
-{
- struct ftrace_event_call *call = filp->private_data;
- char buf[16];
- int r = 0;
-
- if (call->type & TRACE_EVENT_TYPE_PRINTF)
- r += sprintf(buf, "printf\n");
-
- if (call->type & TRACE_EVENT_TYPE_RAW)
- r += sprintf(buf+r, "raw\n");
-
- return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
-}
-
-static ssize_t
-event_type_write(struct file *filp, const char __user *ubuf, size_t cnt,
- loff_t *ppos)
-{
- struct ftrace_event_call *call = filp->private_data;
- char buf[64];
-
- /*
- * If there's only one type, we can't change it.
- * And currently we always have printf type, and we
- * may or may not have raw type.
- *
- * This is a redundant check, the file should be read
- * only if this is the case anyway.
- */
-
- if (!call->raw_init)
- return -EPERM;
-
- if (cnt >= sizeof(buf))
- return -EINVAL;
-
- if (copy_from_user(&buf, ubuf, cnt))
- return -EFAULT;
-
- buf[cnt] = 0;
-
- if (!strncmp(buf, "printf", 6) &&
- (!buf[6] || isspace(buf[6]))) {
-
- call->type = TRACE_EVENT_TYPE_PRINTF;
-
- /*
- * If raw enabled, the disable it and enable
- * printf type.
- */
- if (call->raw_enabled) {
- call->raw_enabled = 0;
- call->raw_unreg();
-
- call->enabled = 1;
- call->regfunc();
- }
-
- } else if (!strncmp(buf, "raw", 3) &&
- (!buf[3] || isspace(buf[3]))) {
-
- call->type = TRACE_EVENT_TYPE_RAW;
-
- /*
- * If printf enabled, the disable it and enable
- * raw type.
- */
- if (call->enabled) {
- call->enabled = 0;
- call->unregfunc();
-
- call->raw_enabled = 1;
- call->raw_reg();
- }
- } else
- return -EINVAL;
-
- *ppos += cnt;
-
- return cnt;
-}
-
-static ssize_t
-event_available_types_read(struct file *filp, char __user *ubuf, size_t cnt,
- loff_t *ppos)
-{
- struct ftrace_event_call *call = filp->private_data;
- char buf[16];
- int r = 0;
-
- r += sprintf(buf, "printf\n");
-
- if (call->raw_init)
- r += sprintf(buf+r, "raw\n");
-
- return simple_read_from_buffer(ubuf, cnt, ppos, buf, r);
-}
-
#undef FIELD
#define FIELD(type, name) \
#type, #name, (unsigned int)offsetof(typeof(field), name), \
FIELD(int, pid),
FIELD(int, tgid));
}
+
static ssize_t
event_format_read(struct file *filp, char __user *ubuf, size_t cnt,
loff_t *ppos)
.stop = t_stop,
};
-static const struct file_operations ftrace_avail_fops = {
- .open = ftrace_event_seq_open,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = seq_release,
-};
-
static const struct file_operations ftrace_set_event_fops = {
.open = ftrace_event_seq_open,
.read = seq_read,
.write = event_enable_write,
};
-static const struct file_operations ftrace_type_fops = {
- .open = tracing_open_generic,
- .read = event_type_read,
- .write = event_type_write,
-};
-
-static const struct file_operations ftrace_available_types_fops = {
- .open = tracing_open_generic,
- .read = event_available_types_read,
-};
-
static const struct file_operations ftrace_event_format_fops = {
.open = tracing_open_generic,
.read = event_format_read,
}
}
- /* default the output to printf */
- call->type = TRACE_EVENT_TYPE_PRINTF;
-
call->dir = debugfs_create_dir(call->name, d_events);
if (!call->dir) {
pr_warning("Could not create debugfs "
"'%s/enable' entry\n", call->name);
}
- /* Only let type be writable, if we can change it */
- entry = debugfs_create_file("type",
- call->raw_init ? 0644 : 0444,
- call->dir, call,
- &ftrace_type_fops);
- if (!entry)
- pr_warning("Could not create debugfs "
- "'%s/type' entry\n", call->name);
-
- entry = debugfs_create_file("available_types", 0444, call->dir, call,
- &ftrace_available_types_fops);
- if (!entry)
- pr_warning("Could not create debugfs "
- "'%s/available_types' entry\n", call->name);
-
/* A trace may not want to export its format */
if (!call->show_format)
return 0;
if (!d_tracer)
return 0;
- entry = debugfs_create_file("available_events", 0444, d_tracer,
- (void *)&show_event_seq_ops,
- &ftrace_avail_fops);
- if (!entry)
- pr_warning("Could not create debugfs "
- "'available_events' entry\n");
-
entry = debugfs_create_file("set_event", 0644, d_tracer,
(void *)&show_set_event_seq_ops,
&ftrace_set_event_fops);