License header fixes
[lttng-tools.git] / src / bin / lttng-sessiond / trace-kernel.h
1 /*
2 * Copyright (C) 2011 - David Goulet <david.goulet@polymtl.ca>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License, version 2 only,
6 * as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 */
17
18 #ifndef _LTT_TRACE_KERNEL_H
19 #define _LTT_TRACE_KERNEL_H
20
21 #include <limits.h>
22 #include <urcu/list.h>
23
24 #include <lttng/lttng.h>
25 #include <common/lttng-kernel.h>
26
27 /* Kernel event list */
28 struct ltt_kernel_event_list {
29 struct cds_list_head head;
30 };
31
32 /* Channel stream list */
33 struct ltt_kernel_stream_list {
34 struct cds_list_head head;
35 };
36
37 /* Channel list */
38 struct ltt_kernel_channel_list {
39 struct cds_list_head head;
40 };
41
42 /* Kernel event */
43 struct ltt_kernel_event {
44 int fd;
45 int enabled;
46 /*
47 * TODO: need internal representation to support more than a
48 * single context.
49 */
50 struct lttng_kernel_context *ctx;
51 struct lttng_kernel_event *event;
52 struct cds_list_head list;
53 };
54
55 /* Kernel channel */
56 struct ltt_kernel_channel {
57 int fd;
58 int enabled;
59 char *pathname;
60 unsigned int stream_count;
61 unsigned int event_count;
62 /*
63 * TODO: need internal representation to support more than a
64 * single context.
65 */
66 struct lttng_kernel_context *ctx;
67 struct lttng_channel *channel;
68 struct ltt_kernel_event_list events_list;
69 struct ltt_kernel_stream_list stream_list;
70 struct cds_list_head list;
71 };
72
73 /* Metadata */
74 struct ltt_kernel_metadata {
75 int fd;
76 char *pathname;
77 struct lttng_channel *conf;
78 };
79
80 /* Channel stream */
81 struct ltt_kernel_stream {
82 int fd;
83 char *pathname;
84 int state;
85 struct cds_list_head list;
86 };
87
88 /* Kernel session */
89 struct ltt_kernel_session {
90 int fd;
91 int metadata_stream_fd;
92 int consumer_fds_sent;
93 int consumer_fd;
94 unsigned int channel_count;
95 unsigned int stream_count_global;
96 char *trace_path;
97 struct ltt_kernel_metadata *metadata;
98 struct ltt_kernel_channel_list channel_list;
99 /* UID/GID of the user owning the session */
100 uid_t uid;
101 gid_t gid;
102 };
103
104 /*
105 * Lookup functions. NULL is returned if not found.
106 */
107 struct ltt_kernel_event *trace_kernel_get_event_by_name(
108 char *name, struct ltt_kernel_channel *channel);
109 struct ltt_kernel_channel *trace_kernel_get_channel_by_name(
110 char *name, struct ltt_kernel_session *session);
111
112 /*
113 * Create functions malloc() the data structure.
114 */
115 struct ltt_kernel_session *trace_kernel_create_session(char *path);
116 struct ltt_kernel_channel *trace_kernel_create_channel(struct lttng_channel *chan, char *path);
117 struct ltt_kernel_event *trace_kernel_create_event(struct lttng_event *ev);
118 struct ltt_kernel_metadata *trace_kernel_create_metadata(char *path);
119 struct ltt_kernel_stream *trace_kernel_create_stream(void);
120
121 /*
122 * Destroy functions free() the data structure and remove from linked list if
123 * it's applies.
124 */
125 void trace_kernel_destroy_session(struct ltt_kernel_session *session);
126 void trace_kernel_destroy_metadata(struct ltt_kernel_metadata *metadata);
127 void trace_kernel_destroy_channel(struct ltt_kernel_channel *channel);
128 void trace_kernel_destroy_event(struct ltt_kernel_event *event);
129 void trace_kernel_destroy_stream(struct ltt_kernel_stream *stream);
130
131 #endif /* _LTT_TRACE_KERNEL_H */
This page took 0.032334 seconds and 4 git commands to generate.