relayd: open live viewer files from the current stream's trace chunk
[lttng-tools.git] / src / common / index / index.h
1 /*
2 * Copyright (C) 2013 - Julien Desfossez <jdesfossez@efficios.com>
3 * David Goulet <dgoulet@efficios.com>
4 * 2016 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
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>
24 #include <urcu/ref.h>
25
26 #include <common/trace-chunk.h>
27 #include "ctf-index.h"
28
29 struct lttng_index_file {
30 int fd;
31 uint32_t major;
32 uint32_t minor;
33 uint32_t element_len;
34 struct lttng_trace_chunk *trace_chunk;
35 struct urcu_ref ref;
36 };
37
38 /*
39 * create and open have refcount of 1. Use put to decrement the
40 * refcount. Destroys when reaching 0. Use "get" to increment refcount.
41 */
42 struct lttng_index_file *lttng_index_file_create_from_trace_chunk(
43 struct lttng_trace_chunk *chunk,
44 const char *channel_path, const char *stream_name,
45 uint64_t stream_file_size, uint64_t stream_count,
46 uint32_t index_major, uint32_t index_minor,
47 bool unlink_existing_file);
48 struct lttng_index_file *lttng_index_file_create_from_trace_chunk_read_only(
49 struct lttng_trace_chunk *chunk,
50 const char *channel_path, const char *stream_name,
51 uint64_t stream_file_size, uint64_t stream_file_index,
52 uint32_t index_major, uint32_t index_minor);
53 int lttng_index_file_write(const struct lttng_index_file *index_file,
54 const struct ctf_packet_index *element);
55 int lttng_index_file_read(const struct lttng_index_file *index_file,
56 struct ctf_packet_index *element);
57
58 void lttng_index_file_get(struct lttng_index_file *index_file);
59 void lttng_index_file_put(struct lttng_index_file *index_file);
60
61 #endif /* _INDEX_H */
This page took 0.032695 seconds and 4 git commands to generate.