aboutsummaryrefslogtreecommitdiffstats
path: root/tools/xentrace
diff options
context:
space:
mode:
authorKeir Fraser <keir.fraser@citrix.com>2007-12-04 10:17:32 +0000
committerKeir Fraser <keir.fraser@citrix.com>2007-12-04 10:17:32 +0000
commit1f74affa2d43cebb224b1ef56a0a6abdbf822e65 (patch)
treeb0f0cabfa2a6236db6bede5b536c2c6a30578397 /tools/xentrace
parent9f0c829d98a76702c7b69b9dc34aaed2d281ce4e (diff)
downloadxen-1f74affa2d43cebb224b1ef56a0a6abdbf822e65.tar.gz
xen-1f74affa2d43cebb224b1ef56a0a6abdbf822e65.tar.bz2
xen-1f74affa2d43cebb224b1ef56a0a6abdbf822e65.zip
xentrace: Don't append trace on existing file.
When you run "xentrace -e <mask> trace.output" the first time, all is fine. When you run it a second time, then the data is appended which makes you reading old data with xentrace_format and you interprete it as new data. This usually happens when you automated tracing guests with xentrace and xentrace_format with a script. Therefore, attached patch makes xentrace to truncate the file to zero bytes before writing any data. Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Diffstat (limited to 'tools/xentrace')
-rw-r--r--tools/xentrace/xentrace.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tools/xentrace/xentrace.c b/tools/xentrace/xentrace.c
index d6fa93e436..26415bdb7d 100644
--- a/tools/xentrace/xentrace.c
+++ b/tools/xentrace/xentrace.c
@@ -572,24 +572,24 @@ int main(int argc, char **argv)
parse_args(argc, argv);
- if (opts.evt_mask != 0) {
+ if ( opts.evt_mask != 0 )
set_mask(opts.evt_mask, 0);
- }
- if (opts.cpu_mask != 0) {
+ if ( opts.cpu_mask != 0 )
set_mask(opts.cpu_mask, 1);
- }
if ( opts.outfile )
- outfd = open(opts.outfile, O_WRONLY | O_CREAT | O_LARGEFILE, 0644);
+ outfd = open(opts.outfile,
+ O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE,
+ 0644);
- if(outfd < 0)
+ if ( outfd < 0 )
{
perror("Could not open output file");
exit(EXIT_FAILURE);
}
- if(isatty(outfd))
+ if ( isatty(outfd) )
{
fprintf(stderr, "Cannot output to a TTY, specify a log file.\n");
exit(EXIT_FAILURE);