Skip to contentSkip to conversation

trace-cmd record: Update filter_command() to use tracefs_instance_file_append()

PATCH Steven Rostedt 1 participant 1 message May 13, 2021

lore
Share & tools
lore
#0 lore raw

From: "Steven Rostedt (VMware)" <[email protected]>

Now that trace-cmd depends on libtracefs 1.2, have filter_command use the tracefs_instance_file_append() as it had originally when first added, instead of open coding it for libtracefs 1.1.

---
 tracecmd/trace-record.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)
tracecmd/trace-record.c +1 -14
index 5219d60b..ba9542ff 100644
@@ -4556,20 +4556,7 @@ enum filter_type {
 
 static int filter_command(struct tracefs_instance *instance, const char *cmd)
 {
-	char *path;
-	int ret;
-	int fd;
-
-	path = tracefs_instance_get_file(instance, "set_ftrace_filter");
-	if (!path)
-		return -1;
-	fd = open(path, O_WRONLY);
-	tracefs_put_tracing_file(path);
-	if (fd < 0)
-		return -1;
-	ret = write(fd, cmd, strlen(cmd));
-	close(fd);
-	return ret;
+	return tracefs_instance_file_append(instance, "set_ftrace_filter", cmd);
 }
 
 static int write_func_filter(enum filter_type type, struct buffer_instance *instance,
Signature · 1 line
2.29.2