aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTzvetomir Stoyanov <tstoyanov@vmware.com>2019-03-11 10:33:37 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-03-12 21:16:48 -0400
commitcd5a23168280917774094eeb77b5a359e4f4a292 (patch)
tree1a1d2d8edaccd3642f3e7fa1000dfb9450092a34
parentcbd567febd2559b055576ec48312fa53f46f76f5 (diff)
downloadtrace-cmd-cd5a23168280917774094eeb77b5a359e4f4a292.tar.gz
trace-cmd: Refactore add_event_pid()to utilize write_instance_file()
This patch changes add_event_pid() to utilize write_instance_file() for writing set_event_pid instance file, instead of directly opening it. Link: http://lore.kernel.org/linux-trace-devel/20190311083339.21581-5-tstoyanov@vmware.com Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com> Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--tracecmd/trace-record.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c
index f1f5d29d..801dad24 100644
--- a/tracecmd/trace-record.c
+++ b/tracecmd/trace-record.c
@@ -1133,30 +1133,25 @@ static void update_sched_events(struct buffer_instance *instance, int pid)
static int open_instance_fd(struct buffer_instance *instance,
const char *file, int flags);
-static void add_event_pid(const char *buf, int len)
+static void add_event_pid(const char *buf)
{
struct buffer_instance *instance;
- int fd;
- for_all_instances(instance) {
- fd = open_instance_fd(instance, "set_event_pid", O_WRONLY);
- write(fd, buf, len);
- close(fd);
- }
+ for_all_instances(instance)
+ write_instance_file(instance, "set_event_pid", buf, "event_pid");
}
static void add_new_filter_pid(int pid)
{
struct buffer_instance *instance;
char buf[100];
- int len;
add_filter_pid(pid, 0);
- len = sprintf(buf, "%d", pid);
+ sprintf(buf, "%d", pid);
update_ftrace_pid(buf, 0);
if (have_set_event_pid)
- return add_event_pid(buf, len);
+ return add_event_pid(buf);
common_pid_filter = append_pid_filter(common_pid_filter, "common_pid", pid);