All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libtracefs: Have echo command concatenate
@ 2022-02-01 22:29 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2022-02-01 22:29 UTC (permalink / raw)
  To: Linux Trace Devel

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

Currently, tracefs_synth_echo_cmd() does a truncate of the file with the
'>'. This can cause issues if the current files have something already in
it, and could even error with EBUSY if the items can not be deleted.

Use the safer concatenate '>>' instead.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/tracefs-hist.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/tracefs-hist.c b/src/tracefs-hist.c
index e7dd279ae3f9..aec61ad52e72 100644
--- a/src/tracefs-hist.c
+++ b/src/tracefs-hist.c
@@ -2196,7 +2196,7 @@ int tracefs_synth_echo_cmd(struct trace_seq *seq,
 	if (!path)
 		goto out_free;
 
-	trace_seq_printf(seq, "echo '%s%s%s %s' > %s/%s\n",
+	trace_seq_printf(seq, "echo '%s%s%s %s' >> %s/%s\n",
 			 synth->dyn_event->prefix,
 			 strlen(synth->dyn_event->prefix) ? ":" : "",
 			 synth->dyn_event->event,
@@ -2211,7 +2211,7 @@ int tracefs_synth_echo_cmd(struct trace_seq *seq,
 	if (!hist)
 		goto out_free;
 
-	trace_seq_printf(seq, "echo '%s' > %s/events/%s/%s/trigger\n",
+	trace_seq_printf(seq, "echo '%s' >> %s/events/%s/%s/trigger\n",
 			 hist, path, synth->start_event->system,
 			 synth->start_event->name);
 	free(hist);
@@ -2221,7 +2221,7 @@ int tracefs_synth_echo_cmd(struct trace_seq *seq,
 	if (!hist)
 		goto out_free;
 
-	trace_seq_printf(seq, "echo '%s' > %s/events/%s/%s/trigger\n",
+	trace_seq_printf(seq, "echo '%s' >> %s/events/%s/%s/trigger\n",
 			 hist, path, synth->end_event->system,
 			 synth->end_event->name);
 
-- 
2.33.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-02-01 22:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01 22:29 [PATCH] libtracefs: Have echo command concatenate Steven Rostedt

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.