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