1 /* SPDX-License-Identifier: GPL-2.0 */
8 #include <linux/types.h>
15 enum perf_dir_version {
16 PERF_DIR_SINGLE_FILE = 0,
20 struct perf_data_file {
31 struct perf_data_file file;
37 enum perf_data_mode mode;
41 struct perf_data_file *files;
46 static inline bool perf_data__is_read(struct perf_data *data)
48 return data->mode == PERF_DATA_MODE_READ;
51 static inline bool perf_data__is_write(struct perf_data *data)
53 return data->mode == PERF_DATA_MODE_WRITE;
56 static inline int perf_data__is_pipe(struct perf_data *data)
61 static inline bool perf_data__is_dir(struct perf_data *data)
66 static inline bool perf_data__is_single_file(struct perf_data *data)
68 return data->dir.version == PERF_DIR_SINGLE_FILE;
71 static inline int perf_data__fd(struct perf_data *data)
74 return fileno(data->file.fptr);
79 int perf_data__open(struct perf_data *data);
80 void perf_data__close(struct perf_data *data);
81 ssize_t perf_data__read(struct perf_data *data, void *buf, size_t size);
82 ssize_t perf_data__write(struct perf_data *data,
83 void *buf, size_t size);
84 ssize_t perf_data_file__write(struct perf_data_file *file,
85 void *buf, size_t size);
87 * If at_exit is set, only rename current perf.data to
88 * perf.data.<postfix>, continue write on original data.
89 * Set at_exit when flushing the last output.
91 * Return value is fd of new output.
93 int perf_data__switch(struct perf_data *data,
95 size_t pos, bool at_exit, char **new_filepath);
97 int perf_data__create_dir(struct perf_data *data, int nr);
98 int perf_data__open_dir(struct perf_data *data);
99 void perf_data__close_dir(struct perf_data *data);
100 int perf_data__update_dir(struct perf_data *data);
101 unsigned long perf_data__size(struct perf_data *data);
102 int perf_data__make_kcore_dir(struct perf_data *data, char *buf, size_t buf_sz);
103 bool has_kcore_dir(const char *path);
104 char *perf_data__kallsyms_name(struct perf_data *data);
105 char *perf_data__guest_kallsyms_name(struct perf_data *data, pid_t machine_pid);
106 bool is_perf_data(const char *path);
107 #endif /* __PERF_DATA_H */