WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] xentrace: Don't append trace on existing

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] xentrace: Don't append trace on existing file.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Wed, 05 Dec 2007 05:40:11 -0800
Delivery-date: Wed, 05 Dec 2007 05:40:52 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1196763452 0
# Node ID 190c2592247d3258d6b2c60939d27928c70ac5ca
# Parent  6e7cf648f7f3486e532be332bb4d832bbfe9784a
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@xxxxxxx>
---
 tools/xentrace/xentrace.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff -r 6e7cf648f7f3 -r 190c2592247d tools/xentrace/xentrace.c
--- a/tools/xentrace/xentrace.c Tue Dec 04 10:13:04 2007 +0000
+++ b/tools/xentrace/xentrace.c Tue Dec 04 10:17:32 2007 +0000
@@ -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);
-
-    if(outfd < 0)
+        outfd = open(opts.outfile,
+                     O_WRONLY | O_CREAT | O_TRUNC | O_LARGEFILE,
+                     0644);
+
+    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);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] xentrace: Don't append trace on existing file., Xen patchbot-unstable <=