diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2015-12-01 15:37:13 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2015-12-01 15:37:13 -0500 |
commit | a90b5a89d4c9e1427cc93f4496501625b093beda (patch) | |
tree | dce0ec0a635f9853be2c40770467784550b7ef2b | |
parent | e19a601a7ab6d33914768972be41951261b95a19 (diff) | |
download | trace-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.c | 2 |
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)); |