Merge branch 'perf/core' of git://git.kernel.org/pub/scm/linux/kernel/git/frederic...
[safe/jmp/linux-2.6] / tools / perf / util / trace-event-read.c
index 4606639..cb54cd0 100644 (file)
@@ -51,6 +51,7 @@ static int long_size;
 static unsigned long   page_size;
 
 static ssize_t calc_data_size;
+static bool repipe;
 
 /* If it fails, the next read will report it */
 static void skip(int size)
@@ -68,6 +69,13 @@ static int do_read(int fd, void *buf, int size)
                if (ret <= 0)
                        return -1;
 
+               if (repipe) {
+                       int retw = write(STDOUT_FILENO, buf, ret);
+
+                       if (retw <= 0 || retw != ret)
+                               die("repiping input file");
+               }
+
                size -= ret;
                buf += ret;
        }
@@ -122,6 +130,13 @@ static char *read_string(void)
                if (!r)
                        die("no data");
 
+               if (repipe) {
+                       int retw = write(STDOUT_FILENO, &c, 1);
+
+                       if (retw <= 0 || retw != r)
+                               die("repiping input file string");
+               }
+
                buf[size++] = c;
 
                if (!c)
@@ -456,7 +471,7 @@ struct record *trace_read_data(int cpu)
        return data;
 }
 
-ssize_t trace_report(int fd)
+ssize_t trace_report(int fd, bool __repipe)
 {
        char buf[BUFSIZ];
        char test[] = { 23, 8, 68 };
@@ -467,6 +482,7 @@ ssize_t trace_report(int fd)
        ssize_t size;
 
        calc_data_size = 1;
+       repipe = __repipe;
 
        input_fd = fd;
 
@@ -501,6 +517,7 @@ ssize_t trace_report(int fd)
 
        size = calc_data_size - 1;
        calc_data_size = 0;
+       repipe = false;
 
        if (show_funcs) {
                print_funcs();