Merge branch 'master' of ssh://git.lttng.org/home/git/lttng-tools
[lttng-tools.git] / libkernelctl / kernelctl.c
1 /*
2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; only version 2
8 * of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 */
19
20 #include <sys/ioctl.h>
21
22 #include <lttng-kernel-ctl.h>
23
24 #include "kernel-ioctl.h"
25
26 int kernctl_create_session(int fd)
27 {
28 return ioctl(fd, LTTNG_KERNEL_SESSION);
29 }
30
31 /* open the metadata global channel */
32 int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
33 {
34 return ioctl(fd, LTTNG_KERNEL_METADATA, chops);
35 }
36
37 int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
38 {
39 return ioctl(fd, LTTNG_KERNEL_CHANNEL, chops);
40 }
41
42 int kernctl_create_stream(int fd)
43 {
44 return ioctl(fd, LTTNG_KERNEL_STREAM);
45 }
46
47 int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
48 {
49 return ioctl(fd, LTTNG_KERNEL_EVENT, ev);
50 }
51
52 int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
53 {
54 return ioctl(fd, LTTNG_KERNEL_CONTEXT, ctx);
55 }
56
57
58 /* Enable event, channel and session ioctl */
59 int kernctl_enable(int fd)
60 {
61 return ioctl(fd, LTTNG_KERNEL_ENABLE);
62 }
63
64 /* Disable event, channel and session ioctl */
65 int kernctl_disable(int fd)
66 {
67 return ioctl(fd, LTTNG_KERNEL_DISABLE);
68 }
69
70 int kernctl_start_session(int fd)
71 {
72 return ioctl(fd, LTTNG_KERNEL_SESSION_START);
73 }
74
75 int kernctl_stop_session(int fd)
76 {
77 return ioctl(fd, LTTNG_KERNEL_SESSION_STOP);
78 }
79
80
81 int kernctl_tracepoint_list(int fd)
82 {
83 return ioctl(fd, LTTNG_KERNEL_TRACEPOINT_LIST);
84 }
85
86 int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
87 {
88 return ioctl(fd, LTTNG_KERNEL_TRACER_VERSION, v);
89 }
90
91 int kernctl_wait_quiescent(int fd)
92 {
93 return ioctl(fd, LTTNG_KERNEL_WAIT_QUIESCENT);
94 }
95
96 int kernctl_calibrate(int fd, struct lttng_kernel_calibrate *calibrate)
97 {
98 return ioctl(fd, LTTNG_KERNEL_CALIBRATE, calibrate);
99 }
100
101
102 int kernctl_buffer_flush(int fd)
103 {
104 return ioctl(fd, RING_BUFFER_FLUSH);
105 }
106
107
108 /* Buffer operations */
109
110 /* For mmap mode, readable without "get" operation */
111
112 /* returns the length to mmap. */
113 int kernctl_get_mmap_len(int fd, unsigned long *len)
114 {
115 return ioctl(fd, RING_BUFFER_GET_MMAP_LEN, len);
116 }
117
118 /* returns the maximum size for sub-buffers. */
119 int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
120 {
121 return ioctl(fd, RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
122 }
123
124 /*
125 * For mmap mode, operate on the current packet (between get/put or
126 * get_next/put_next).
127 */
128
129 /* returns the offset of the subbuffer belonging to the mmap reader. */
130 int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
131 {
132 return ioctl(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
133 }
134
135 /* returns the size of the current sub-buffer, without padding (for mmap). */
136 int kernctl_get_subbuf_size(int fd, unsigned long *len)
137 {
138 return ioctl(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
139 }
140
141 /* returns the size of the current sub-buffer, without padding (for mmap). */
142 int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
143 {
144 return ioctl(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
145 }
146
147 /* Get exclusive read access to the next sub-buffer that can be read. */
148 int kernctl_get_next_subbuf(int fd)
149 {
150 return ioctl(fd, RING_BUFFER_GET_NEXT_SUBBUF);
151 }
152
153
154 /* Release exclusive sub-buffer access, move consumer forward. */
155 int kernctl_put_next_subbuf(int fd)
156 {
157 return ioctl(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
158 }
159
160 /* snapshot */
161
162 /* Get a snapshot of the current ring buffer producer and consumer positions */
163 int kernctl_snapshot(int fd)
164 {
165 return ioctl(fd, RING_BUFFER_SNAPSHOT);
166 }
167
168 /* Get the consumer position (iteration start) */
169 int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
170 {
171 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
172 }
173
174 /* Get the producer position (iteration end) */
175 int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
176 {
177 return ioctl(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
178 }
179
180 /* Get exclusive read access to the specified sub-buffer position */
181 int kernctl_get_subbuf(int fd, unsigned long *len)
182 {
183 return ioctl(fd, RING_BUFFER_GET_SUBBUF, len);
184 }
185
186 /* Release exclusive sub-buffer access */
187 int kernctl_put_subbuf(int fd)
188 {
189 return ioctl(fd, RING_BUFFER_PUT_SUBBUF);
190 }
This page took 0.049616 seconds and 5 git commands to generate.