Skip to contentSkip to conversation

xentrace: Don't append trace on existing file

PATCH New Christoph Egger 1 participant 1 message Nov 29, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xentrace: Don't append trace on existing file

Hi!

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.

Signature · 12 lines
AMD Saxony, Dresden, Germany
Operating System Research Center

Legal Information:
AMD Saxony Limited Liability Company & Co. KG
Sitz (Geschäftsanschrift):
   Wilschdorfer Landstr. 101, 01109 Dresden, Deutschland
Registergericht Dresden: HRA 4896
vertretungsberechtigter Komplementär:
   AMD Saxony LLC (Sitz Wilmington, Delaware, USA)
Geschäftsführer der AMD Saxony LLC:
   Dr. Hans-R. Deppe, Thomas McCoy
tools/xentrace/xentrace.c +3 -1
diff -r e10eacec8b91 tools/xentrace/xentrace.c
@@ -581,7 +581,9 @@ int main(int argc, char **argv)
     }
 
     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)
     {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel