Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add perf_data_file__write interface

Adding perf_data_file__write interface to centralize output to files.
The function prototype is:

ssize_t perf_data_file__write(struct perf_data_file *file,
void *buf, size_t size);

Returns number of bytes written or -1 in case of error.

NOTE: Also indenting 'struct perf_data_file' members, no functional
change done.

Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1385634619-8129-6-git-send-email-jolsa@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Jiri Olsa and committed by
Arnaldo Carvalho de Melo
6f9a317f bc3a502b

+14 -6
+6
tools/perf/util/data.c
··· 118 118 { 119 119 close(file->fd); 120 120 } 121 + 122 + ssize_t perf_data_file__write(struct perf_data_file *file, 123 + void *buf, size_t size) 124 + { 125 + return writen(file->fd, buf, size); 126 + }
+8 -6
tools/perf/util/data.h
··· 9 9 }; 10 10 11 11 struct perf_data_file { 12 - const char *path; 13 - int fd; 14 - bool is_pipe; 15 - bool force; 16 - unsigned long size; 17 - enum perf_data_mode mode; 12 + const char *path; 13 + int fd; 14 + bool is_pipe; 15 + bool force; 16 + unsigned long size; 17 + enum perf_data_mode mode; 18 18 }; 19 19 20 20 static inline bool perf_data_file__is_read(struct perf_data_file *file) ··· 44 44 45 45 int perf_data_file__open(struct perf_data_file *file); 46 46 void perf_data_file__close(struct perf_data_file *file); 47 + ssize_t perf_data_file__write(struct perf_data_file *file, 48 + void *buf, size_t size); 47 49 48 50 #endif /* __PERF_DATA_H */