aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-12-01 15:37:13 -0500
committerSteven Rostedt <rostedt@goodmis.org>2015-12-01 15:37:13 -0500
commita90b5a89d4c9e1427cc93f4496501625b093beda (patch)
treedce0ec0a635f9853be2c40770467784550b7ef2b
parente19a601a7ab6d33914768972be41951261b95a19 (diff)
downloadtrace-cmd-a90b5a89d4c9e1427cc93f4496501625b093beda.tar.gz
trace-cmd: Truncate files when writing to them
Some files require truncation to happen to make them do anything, like writing "" to them. For reseting the files (and writing to debugfs files in general), open with O_TRUNC, to reset them as they are opened. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-record.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/trace-record.c b/trace-record.c
index cf30176c..df828830 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -1498,7 +1498,7 @@ static int write_file(const char *file, const char *str, const char *type)
int fd;
int ret;
- fd = open(file, O_WRONLY);
+ fd = open(file, O_WRONLY | O_TRUNC);
if (fd < 0)
die("opening to '%s'", file);
ret = write(fd, str, strlen(str));