Commit | Line | Data |
---|---|---|
e98a2d6e | 1 | /* |
0235b0db | 2 | * SPDX-License-Identifier: MIT |
e98a2d6e | 3 | * |
0235b0db | 4 | * Copyright (C) 2016 Philippe Proulx <pproulx@efficios.com> |
e98a2d6e PP |
5 | */ |
6 | ||
0235b0db MJ |
7 | #ifndef CTF_FS_DS_FILE_H |
8 | #define CTF_FS_DS_FILE_H | |
9 | ||
e98a2d6e | 10 | #include <glib.h> |
c802cacb SM |
11 | #include <stdio.h> |
12 | ||
3fadfbc0 | 13 | #include <babeltrace2/babeltrace.h> |
e98a2d6e | 14 | |
5656cea5 | 15 | #include "../common/src/msg-iter/msg-iter.hpp" |
b6c3dcb2 | 16 | |
4164020e SM |
17 | struct ctf_fs_ds_file_info |
18 | { | |
19 | /* Owned by this. */ | |
afb0f12b | 20 | GString *path = nullptr; |
97ade20b | 21 | |
4164020e | 22 | /* Guaranteed to be set, as opposed to the index. */ |
afb0f12b | 23 | int64_t begin_ns = 0; |
97ade20b JG |
24 | }; |
25 | ||
4164020e SM |
26 | struct ctf_fs_ds_file |
27 | { | |
afb0f12b | 28 | bt_logging_level log_level = (bt_logging_level) 0; |
98903a3e | 29 | |
4164020e | 30 | /* Weak */ |
afb0f12b | 31 | bt_self_component *self_comp = nullptr; |
4c65a157 | 32 | |
4164020e | 33 | /* Weak */ |
afb0f12b | 34 | struct ctf_fs_metadata *metadata = nullptr; |
5c563278 | 35 | |
4164020e | 36 | /* Owned by this */ |
afb0f12b | 37 | struct ctf_fs_file *file = nullptr; |
97ade20b | 38 | |
4164020e | 39 | /* Owned by this */ |
afb0f12b | 40 | bt_stream *stream = nullptr; |
97ade20b | 41 | |
afb0f12b | 42 | void *mmap_addr = nullptr; |
97ade20b | 43 | |
4164020e SM |
44 | /* |
45 | * Max length of chunk to mmap() when updating the current mapping. | |
46 | * This value must be page-aligned. | |
47 | */ | |
afb0f12b | 48 | size_t mmap_max_len = 0; |
97ade20b | 49 | |
4164020e | 50 | /* Length of the current mapping. Never exceeds the file's length. */ |
afb0f12b | 51 | size_t mmap_len = 0; |
97ade20b | 52 | |
4164020e | 53 | /* Offset in the file where the current mapping starts. */ |
afb0f12b | 54 | off_t mmap_offset_in_file = 0; |
97ade20b | 55 | |
4164020e SM |
56 | /* |
57 | * Offset, in the current mapping, of the address to return on the next | |
58 | * request. | |
59 | */ | |
afb0f12b | 60 | off_t request_offset_in_mapping = 0; |
b6c3dcb2 | 61 | }; |
e98a2d6e | 62 | |
76edbcf1 SM |
63 | struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream, |
64 | const char *path, bt_logging_level log_level); | |
e98a2d6e | 65 | |
94cf822e | 66 | void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); |
e98a2d6e | 67 | |
4164020e SM |
68 | struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file, |
69 | struct ctf_fs_ds_file_info *ds_file_info, | |
70 | struct ctf_msg_iter *msg_iter); | |
97ade20b | 71 | |
4c65a157 | 72 | struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level, |
4164020e | 73 | bt_self_component *self_comp); |
7ed5243a | 74 | |
97ade20b JG |
75 | void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index); |
76 | ||
f6e68e70 SM |
77 | /* |
78 | * Medium operations to iterate on a single ctf_fs_ds_file. | |
79 | * | |
80 | * The data pointer when using this must be a pointer to the ctf_fs_ds_file. | |
81 | */ | |
18a1979b | 82 | extern struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops; |
6de92955 | 83 | |
f6e68e70 SM |
84 | /* |
85 | * Medium operations to iterate on the packet of a ctf_fs_ds_group. | |
86 | * | |
87 | * The iteration is done based on the index of the group. | |
88 | * | |
89 | * The data pointer when using these medops must be a pointer to a ctf_fs_ds | |
90 | * group_medops_data structure. | |
91 | */ | |
92 | extern struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops; | |
93 | ||
f6e68e70 | 94 | enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create( |
4164020e SM |
95 | struct ctf_fs_ds_file_group *ds_file_group, bt_self_message_iterator *self_msg_iter, |
96 | bt_logging_level log_level, struct ctf_fs_ds_group_medops_data **out); | |
f6e68e70 | 97 | |
f6e68e70 SM |
98 | void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data); |
99 | ||
4164020e | 100 | void ctf_fs_ds_group_medops_data_destroy(struct ctf_fs_ds_group_medops_data *data); |
f6e68e70 | 101 | |
94cf822e | 102 | #endif /* CTF_FS_DS_FILE_H */ |