| 1 | /* |
| 2 | * Copyright (C) 2019 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com> |
| 3 | * Copyright (C) 2020 Jérémie Galarneau <jeremie.galarneau@efficios.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: LGPL-2.1-only |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | #ifndef LTTNG_COMMON_TRACKER_H |
| 10 | #define LTTNG_COMMON_TRACKER_H |
| 11 | |
| 12 | #include <common/buffer-view.hpp> |
| 13 | #include <common/dynamic-array.hpp> |
| 14 | #include <common/macros.hpp> |
| 15 | #include <common/sessiond-comm/sessiond-comm.hpp> |
| 16 | |
| 17 | #include <lttng/lttng-error.h> |
| 18 | #include <lttng/tracker.h> |
| 19 | |
| 20 | struct process_attr_value { |
| 21 | enum lttng_process_attr_value_type type; |
| 22 | union value { |
| 23 | pid_t pid; |
| 24 | uid_t uid; |
| 25 | char *user_name; |
| 26 | gid_t gid; |
| 27 | char *group_name; |
| 28 | } value; |
| 29 | }; |
| 30 | |
| 31 | struct lttng_process_attr_values { |
| 32 | /* Array of struct process_attr_tracker_value. */ |
| 33 | struct lttng_dynamic_pointer_array array; |
| 34 | }; |
| 35 | |
| 36 | const char *lttng_process_attr_to_string(enum lttng_process_attr process_attr); |
| 37 | |
| 38 | struct lttng_process_attr_values *lttng_process_attr_values_create(); |
| 39 | |
| 40 | /* Prefixed with '_' since the name conflicts with a public API. */ |
| 41 | unsigned int _lttng_process_attr_values_get_count(const struct lttng_process_attr_values *values); |
| 42 | |
| 43 | const struct process_attr_value * |
| 44 | lttng_process_attr_tracker_values_get_at_index(const struct lttng_process_attr_values *values, |
| 45 | unsigned int index); |
| 46 | |
| 47 | int lttng_process_attr_values_serialize(const struct lttng_process_attr_values *values, |
| 48 | struct lttng_dynamic_buffer *buffer); |
| 49 | |
| 50 | ssize_t lttng_process_attr_values_create_from_buffer(enum lttng_domain_type domain, |
| 51 | enum lttng_process_attr process_attr, |
| 52 | const struct lttng_buffer_view *buffer_view, |
| 53 | struct lttng_process_attr_values **_values); |
| 54 | |
| 55 | void lttng_process_attr_values_destroy(struct lttng_process_attr_values *values); |
| 56 | |
| 57 | struct process_attr_value *process_attr_value_copy(const struct process_attr_value *value); |
| 58 | |
| 59 | unsigned long process_attr_value_hash(const struct process_attr_value *a); |
| 60 | |
| 61 | bool process_attr_tracker_value_equal(const struct process_attr_value *a, |
| 62 | const struct process_attr_value *b); |
| 63 | |
| 64 | void process_attr_value_destroy(struct process_attr_value *value); |
| 65 | |
| 66 | enum lttng_error_code |
| 67 | process_attr_value_from_comm(enum lttng_domain_type domain, |
| 68 | enum lttng_process_attr process_attr, |
| 69 | enum lttng_process_attr_value_type value_type, |
| 70 | const struct process_attr_integral_value_comm *integral_value, |
| 71 | const struct lttng_buffer_view *value_view, |
| 72 | struct process_attr_value **value); |
| 73 | |
| 74 | #endif /* LTTNG_COMMON_TRACKER_H */ |