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 | |
c802cacb SM |
15 | #include "common/macros.h" |
16 | ||
087cd0f5 SM |
17 | #include "../common/msg-iter/msg-iter.hpp" |
18 | #include "lttng-index.hpp" | |
b6c3dcb2 JG |
19 | |
20 | struct ctf_fs_component; | |
21 | struct ctf_fs_file; | |
1a9f7075 | 22 | struct ctf_fs_trace; |
94cf822e | 23 | struct ctf_fs_ds_file; |
f6e68e70 SM |
24 | struct ctf_fs_ds_file_group; |
25 | struct ctf_fs_ds_group_medops_data; | |
b6c3dcb2 | 26 | |
4164020e SM |
27 | struct ctf_fs_ds_file_info |
28 | { | |
29 | /* Owned by this. */ | |
30 | GString *path; | |
97ade20b | 31 | |
4164020e SM |
32 | /* Guaranteed to be set, as opposed to the index. */ |
33 | int64_t begin_ns; | |
97ade20b JG |
34 | }; |
35 | ||
44c440bc PP |
36 | struct ctf_fs_metadata; |
37 | ||
4164020e SM |
38 | struct ctf_fs_ds_file |
39 | { | |
40 | bt_logging_level log_level; | |
98903a3e | 41 | |
4164020e SM |
42 | /* Weak */ |
43 | bt_self_component *self_comp; | |
4c65a157 | 44 | |
4164020e SM |
45 | /* Weak */ |
46 | struct ctf_fs_metadata *metadata; | |
5c563278 | 47 | |
4164020e SM |
48 | /* Owned by this */ |
49 | struct ctf_fs_file *file; | |
97ade20b | 50 | |
4164020e SM |
51 | /* Owned by this */ |
52 | bt_stream *stream; | |
97ade20b | 53 | |
4164020e | 54 | void *mmap_addr; |
97ade20b | 55 | |
4164020e SM |
56 | /* |
57 | * Max length of chunk to mmap() when updating the current mapping. | |
58 | * This value must be page-aligned. | |
59 | */ | |
60 | size_t mmap_max_len; | |
97ade20b | 61 | |
4164020e SM |
62 | /* Length of the current mapping. Never exceeds the file's length. */ |
63 | size_t mmap_len; | |
97ade20b | 64 | |
4164020e SM |
65 | /* Offset in the file where the current mapping starts. */ |
66 | off_t mmap_offset_in_file; | |
97ade20b | 67 | |
4164020e SM |
68 | /* |
69 | * Offset, in the current mapping, of the address to return on the next | |
70 | * request. | |
71 | */ | |
72 | off_t request_offset_in_mapping; | |
b6c3dcb2 | 73 | }; |
e98a2d6e | 74 | |
76edbcf1 SM |
75 | struct ctf_fs_ds_file *ctf_fs_ds_file_create(struct ctf_fs_trace *ctf_fs_trace, bt_stream *stream, |
76 | const char *path, bt_logging_level log_level); | |
e98a2d6e | 77 | |
94cf822e | 78 | void ctf_fs_ds_file_destroy(struct ctf_fs_ds_file *stream); |
e98a2d6e | 79 | |
4164020e SM |
80 | struct ctf_fs_ds_index *ctf_fs_ds_file_build_index(struct ctf_fs_ds_file *ds_file, |
81 | struct ctf_fs_ds_file_info *ds_file_info, | |
82 | struct ctf_msg_iter *msg_iter); | |
97ade20b | 83 | |
4c65a157 | 84 | struct ctf_fs_ds_index *ctf_fs_ds_index_create(bt_logging_level log_level, |
4164020e | 85 | bt_self_component *self_comp); |
7ed5243a | 86 | |
97ade20b JG |
87 | void ctf_fs_ds_index_destroy(struct ctf_fs_ds_index *index); |
88 | ||
f6e68e70 SM |
89 | /* |
90 | * Medium operations to iterate on a single ctf_fs_ds_file. | |
91 | * | |
92 | * The data pointer when using this must be a pointer to the ctf_fs_ds_file. | |
93 | */ | |
18a1979b | 94 | extern struct ctf_msg_iter_medium_ops ctf_fs_ds_file_medops; |
6de92955 | 95 | |
f6e68e70 SM |
96 | /* |
97 | * Medium operations to iterate on the packet of a ctf_fs_ds_group. | |
98 | * | |
99 | * The iteration is done based on the index of the group. | |
100 | * | |
101 | * The data pointer when using these medops must be a pointer to a ctf_fs_ds | |
102 | * group_medops_data structure. | |
103 | */ | |
104 | extern struct ctf_msg_iter_medium_ops ctf_fs_ds_group_medops; | |
105 | ||
f6e68e70 | 106 | enum ctf_msg_iter_medium_status ctf_fs_ds_group_medops_data_create( |
4164020e SM |
107 | struct ctf_fs_ds_file_group *ds_file_group, bt_self_message_iterator *self_msg_iter, |
108 | bt_logging_level log_level, struct ctf_fs_ds_group_medops_data **out); | |
f6e68e70 | 109 | |
f6e68e70 SM |
110 | void ctf_fs_ds_group_medops_data_reset(struct ctf_fs_ds_group_medops_data *data); |
111 | ||
4164020e | 112 | void ctf_fs_ds_group_medops_data_destroy(struct ctf_fs_ds_group_medops_data *data); |
f6e68e70 | 113 | |
94cf822e | 114 | #endif /* CTF_FS_DS_FILE_H */ |