Commit | Line | Data |
---|---|---|
309167d2 JD |
1 | /* |
2 | * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com> | |
3 | * David Goulet <dgoulet@efficios.com> | |
f8f3885c | 4 | * 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com> |
309167d2 JD |
5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | |
7 | * under the terms of the GNU General Public License, version 2 only, as | |
8 | * published by the Free Software Foundation. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License along with | |
16 | * this program; if not, write to the Free Software Foundation, Inc., 51 | |
17 | * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 | */ | |
19 | ||
20 | #ifndef _INDEX_H | |
21 | #define _INDEX_H | |
22 | ||
23 | #include <inttypes.h> | |
f8f3885c | 24 | #include <urcu/ref.h> |
309167d2 | 25 | |
50adc264 | 26 | #include "ctf-index.h" |
8bb66c3c JG |
27 | #include <common/fs-handle.h> |
28 | #include <common/trace-chunk.h> | |
309167d2 | 29 | |
f8f3885c | 30 | struct lttng_index_file { |
8bb66c3c | 31 | struct fs_handle *file; |
f8f3885c MD |
32 | uint32_t major; |
33 | uint32_t minor; | |
34 | uint32_t element_len; | |
c35f9726 | 35 | struct lttng_trace_chunk *trace_chunk; |
f8f3885c MD |
36 | struct urcu_ref ref; |
37 | }; | |
38 | ||
39 | /* | |
40 | * create and open have refcount of 1. Use put to decrement the | |
41 | * refcount. Destroys when reaching 0. Use "get" to increment refcount. | |
42 | */ | |
3ff5c5db | 43 | enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk( |
d2956687 | 44 | struct lttng_trace_chunk *chunk, |
ebb29c10 | 45 | const char *channel_path, const char *stream_name, |
d2956687 JG |
46 | uint64_t stream_file_size, uint64_t stream_count, |
47 | uint32_t index_major, uint32_t index_minor, | |
3ff5c5db MD |
48 | bool unlink_existing_file, struct lttng_index_file **file); |
49 | ||
50 | enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only( | |
ebb29c10 JG |
51 | struct lttng_trace_chunk *chunk, |
52 | const char *channel_path, const char *stream_name, | |
53 | uint64_t stream_file_size, uint64_t stream_file_index, | |
3ff5c5db MD |
54 | uint32_t index_major, uint32_t index_minor, |
55 | bool expect_no_file, struct lttng_index_file **file); | |
56 | ||
f8f3885c MD |
57 | int lttng_index_file_write(const struct lttng_index_file *index_file, |
58 | const struct ctf_packet_index *element); | |
59 | int lttng_index_file_read(const struct lttng_index_file *index_file, | |
60 | struct ctf_packet_index *element); | |
61 | ||
62 | void lttng_index_file_get(struct lttng_index_file *index_file); | |
63 | void lttng_index_file_put(struct lttng_index_file *index_file); | |
309167d2 JD |
64 | |
65 | #endif /* _INDEX_H */ |