c7bc656823b9138fbd15827c273a8cec82e2a3bd
[lttng-tools.git] / src / common / index / index.h
1 /*
2 * Copyright (C) 2013 Julien Desfossez <jdesfossez@efficios.com>
3 * Copyright (C) 2013 David Goulet <dgoulet@efficios.com>
4 * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0-only
7 *
8 */
9
10 #ifndef _INDEX_H
11 #define _INDEX_H
12
13 #include <inttypes.h>
14 #include <urcu/ref.h>
15
16 #include "ctf-index.h"
17 #include <common/fs-handle.h>
18 #include <common/trace-chunk.h>
19
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23
24 struct lttng_index_file {
25 struct fs_handle *file;
26 uint32_t major;
27 uint32_t minor;
28 uint32_t element_len;
29 struct lttng_trace_chunk *trace_chunk;
30 struct urcu_ref ref;
31 };
32
33 /*
34 * create and open have refcount of 1. Use put to decrement the
35 * refcount. Destroys when reaching 0. Use "get" to increment refcount.
36 */
37 enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk(
38 struct lttng_trace_chunk *chunk,
39 const char *channel_path, const char *stream_name,
40 uint64_t stream_file_size, uint64_t stream_count,
41 uint32_t index_major, uint32_t index_minor,
42 bool unlink_existing_file, struct lttng_index_file **file);
43
44 enum lttng_trace_chunk_status lttng_index_file_create_from_trace_chunk_read_only(
45 struct lttng_trace_chunk *chunk,
46 const char *channel_path, const char *stream_name,
47 uint64_t stream_file_size, uint64_t stream_file_index,
48 uint32_t index_major, uint32_t index_minor,
49 bool expect_no_file, struct lttng_index_file **file);
50
51 int lttng_index_file_write(const struct lttng_index_file *index_file,
52 const struct ctf_packet_index *element);
53 int lttng_index_file_read(const struct lttng_index_file *index_file,
54 struct ctf_packet_index *element);
55
56 void lttng_index_file_get(struct lttng_index_file *index_file);
57 void lttng_index_file_put(struct lttng_index_file *index_file);
58
59 #ifdef __cplusplus
60 }
61 #endif
62
63 #endif /* _INDEX_H */
This page took 0.029569 seconds and 3 git commands to generate.