at v4.14 60 lines 1.4 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef __PERF_DATA_H 3#define __PERF_DATA_H 4 5#include <stdbool.h> 6 7enum perf_data_mode { 8 PERF_DATA_MODE_WRITE, 9 PERF_DATA_MODE_READ, 10}; 11 12struct perf_data_file { 13 const char *path; 14 int fd; 15 bool is_pipe; 16 bool force; 17 unsigned long size; 18 enum perf_data_mode mode; 19}; 20 21static inline bool perf_data_file__is_read(struct perf_data_file *file) 22{ 23 return file->mode == PERF_DATA_MODE_READ; 24} 25 26static inline bool perf_data_file__is_write(struct perf_data_file *file) 27{ 28 return file->mode == PERF_DATA_MODE_WRITE; 29} 30 31static inline int perf_data_file__is_pipe(struct perf_data_file *file) 32{ 33 return file->is_pipe; 34} 35 36static inline int perf_data_file__fd(struct perf_data_file *file) 37{ 38 return file->fd; 39} 40 41static inline unsigned long perf_data_file__size(struct perf_data_file *file) 42{ 43 return file->size; 44} 45 46int perf_data_file__open(struct perf_data_file *file); 47void perf_data_file__close(struct perf_data_file *file); 48ssize_t perf_data_file__write(struct perf_data_file *file, 49 void *buf, size_t size); 50/* 51 * If at_exit is set, only rename current perf.data to 52 * perf.data.<postfix>, continue write on original file. 53 * Set at_exit when flushing the last output. 54 * 55 * Return value is fd of new output. 56 */ 57int perf_data_file__switch(struct perf_data_file *file, 58 const char *postfix, 59 size_t pos, bool at_exit); 60#endif /* __PERF_DATA_H */