| 1 | /* |
| 2 | * Copyright (C) 2013 David Goulet <dgoulet@efficios.com> |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0-only |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef SNAPSHOT_H |
| 9 | #define SNAPSHOT_H |
| 10 | |
| 11 | #include "consumer.hpp" |
| 12 | |
| 13 | #include <common/common.hpp> |
| 14 | #include <common/hashtable/hashtable.hpp> |
| 15 | #include <common/uri.hpp> |
| 16 | |
| 17 | #include <limits.h> |
| 18 | #include <stdint.h> |
| 19 | |
| 20 | struct consumer_output; |
| 21 | |
| 22 | struct snapshot_output { |
| 23 | uint32_t id = 0; |
| 24 | uint64_t max_size = 0; |
| 25 | /* Number of snapshot taken with that output. */ |
| 26 | uint64_t nb_snapshot = 0; |
| 27 | char name[NAME_MAX] = {}; |
| 28 | struct consumer_output *consumer = nullptr; |
| 29 | bool kernel_sockets_copied = false; |
| 30 | bool ust_sockets_copied = false; |
| 31 | /* |
| 32 | * Contains the string with "<date>-<time>" for when the snapshot command |
| 33 | * is triggered. This is to make sure every streams will use the same time |
| 34 | * for the directory output. |
| 35 | */ |
| 36 | char datetime[16] = {}; |
| 37 | |
| 38 | /* Indexed by ID. */ |
| 39 | struct lttng_ht_node_ulong node = {}; |
| 40 | }; |
| 41 | |
| 42 | struct snapshot { |
| 43 | unsigned long next_output_id; |
| 44 | size_t nb_output; |
| 45 | /* |
| 46 | * Number of snapshot taken for that object. This value is used with a |
| 47 | * temporary output of a snapshot record. |
| 48 | */ |
| 49 | uint64_t nb_snapshot; |
| 50 | struct lttng_ht *output_ht; |
| 51 | }; |
| 52 | |
| 53 | /* Snapshot object. */ |
| 54 | struct snapshot *snapshot_alloc(); |
| 55 | void snapshot_destroy(struct snapshot *obj); |
| 56 | int snapshot_init(struct snapshot *obj); |
| 57 | void snapshot_delete_output(struct snapshot *snapshot, struct snapshot_output *output); |
| 58 | void snapshot_add_output(struct snapshot *snapshot, struct snapshot_output *output); |
| 59 | |
| 60 | /* Snapshot output object. */ |
| 61 | struct snapshot_output *snapshot_output_alloc(); |
| 62 | void snapshot_output_destroy(struct snapshot_output *obj); |
| 63 | |
| 64 | struct snapshot_output *snapshot_find_output_by_id(uint32_t id, struct snapshot *snapshot); |
| 65 | struct snapshot_output *snapshot_find_output_by_name(const char *name, struct snapshot *snapshot); |
| 66 | |
| 67 | #endif /* SNAPSHOT_H */ |