1 /* SPDX-License-Identifier: GPL-2.0 */
7 #include <linux/types.h>
14 enum perf_dir_version {
15 PERF_DIR_SINGLE_FILE = 0,
19 struct perf_data_file {
30 struct perf_data_file file;
36 enum perf_data_mode mode;
40 struct perf_data_file *files;
45 static inline bool perf_data__is_read(struct perf_data *data)
47 return data->mode == PERF_DATA_MODE_READ;
50 static inline bool perf_data__is_write(struct perf_data *data)
52 return data->mode == PERF_DATA_MODE_WRITE;
55 static inline int perf_data__is_pipe(struct perf_data *data)
60 static inline bool perf_data__is_dir(struct perf_data *data)
65 static inline bool perf_data__is_single_file(struct perf_data *data)
67 return data->dir.version == PERF_DIR_SINGLE_FILE;
70 static inline int perf_data__fd(struct perf_data *data)
73 return fileno(data->file.fptr);
78 int perf_data__open(struct perf_data *data);
79 void perf_data__close(struct perf_data *data);
80 ssize_t perf_data__read(struct perf_data *data, void *buf, size_t size);
81 ssize_t perf_data__write(struct perf_data *data,
82 void *buf, size_t size);
83 ssize_t perf_data_file__write(struct perf_data_file *file,
84 void *buf, size_t size);
86 * If at_exit is set, only rename current perf.data to
87 * perf.data.<postfix>, continue write on original data.
88 * Set at_exit when flushing the last output.
90 * Return value is fd of new output.
92 int perf_data__switch(struct perf_data *data,
94 size_t pos, bool at_exit, char **new_filepath);
96 int perf_data__create_dir(struct perf_data *data, int nr);
97 int perf_data__open_dir(struct perf_data *data);
98 void perf_data__close_dir(struct perf_data *data);
99 int perf_data__update_dir(struct perf_data *data);
100 unsigned long perf_data__size(struct perf_data *data);
101 int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz);
102 bool has_kcore_dir(const char *path);
103 char *perf_data__kallsyms_name(struct perf_data *data);
104 bool is_perf_data(const char *path);
105 #endif /* __PERF_DATA_H */