trackers: introduce new tracker types
[lttng-tools.git] / src / common / kernel-ctl / kernel-ctl.c
CommitLineData
ee0326c0 1/*
16421f6e
DG
2 * Copyright (C) 2011 - Julien Desfossez <julien.desfossez@polymtl.ca>
3 * Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
a6bd6d9b 4 * 2016 - Jérémie Galarneau <jeremie.galarneau@efficios.com>
ee0326c0 5 *
d14d33bf
AM
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License, version 2 only,
8 * as published by the Free Software Foundation.
ee0326c0
DG
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 *
d14d33bf
AM
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
ee0326c0 18 */
16421f6e 19
6c1c0768 20#define _LGPL_SOURCE
95ba0f2f 21#define __USE_LINUX_IOCTL_DEFS
16421f6e 22#include <sys/ioctl.h>
4dbc372b 23#include <string.h>
46820c8b 24#include <common/align.h>
8ff4109e 25#include <common/macros.h>
00a62084 26#include <errno.h>
a6bd6d9b
JG
27#include <stdarg.h>
28#include <assert.h>
e04b2181 29#include <common/time.h>
16421f6e 30
10a8a223 31#include "kernel-ctl.h"
16421f6e 32#include "kernel-ioctl.h"
16421f6e 33
5226f1bc 34#define LTTNG_IOCTL_CHECK(fildes, request, ...) ({ \
a6bd6d9b
JG
35 int ret = ioctl(fildes, request, ##__VA_ARGS__);\
36 assert(ret <= 0); \
5226f1bc
JG
37 !ret ? 0 : -errno; \
38})
39
40#define LTTNG_IOCTL_NO_CHECK(fildes, request, ...) ({ \
41 int ret = ioctl(fildes, request, ##__VA_ARGS__);\
42 ret >= 0 ? ret : -errno; \
a6bd6d9b
JG
43})
44
4dbc372b
JD
45/*
46 * This flag indicates which version of the kernel ABI to use. The old
47 * ABI (namespace _old) does not support a 32-bit user-space when the
48 * kernel is 64-bit. The old ABI is kept here for compatibility but is
49 * deprecated and will be removed eventually.
50 */
51static int lttng_kernel_use_old_abi = -1;
52
53/*
54 * Execute the new or old ioctl depending on the ABI version.
55 * If the ABI version is not determined yet (lttng_kernel_use_old_abi = -1),
56 * this function tests if the new ABI is available and otherwise fallbacks
57 * on the old one.
58 * This function takes the fd on which the ioctl must be executed and the old
59 * and new request codes.
60 * It returns the return value of the ioctl executed.
61 */
62static inline int compat_ioctl_no_arg(int fd, unsigned long oldname,
63 unsigned long newname)
64{
65 int ret;
66
67 if (lttng_kernel_use_old_abi == -1) {
5226f1bc 68 ret = LTTNG_IOCTL_NO_CHECK(fd, newname);
4dbc372b
JD
69 if (!ret) {
70 lttng_kernel_use_old_abi = 0;
71 goto end;
72 }
73 lttng_kernel_use_old_abi = 1;
74 }
75 if (lttng_kernel_use_old_abi) {
5226f1bc 76 ret = LTTNG_IOCTL_NO_CHECK(fd, oldname);
4dbc372b 77 } else {
5226f1bc 78 ret = LTTNG_IOCTL_NO_CHECK(fd, newname);
4dbc372b
JD
79 }
80
81end:
82 return ret;
83}
84
964ccb60 85int kernctl_create_session(int fd)
d65106b1 86{
4dbc372b
JD
87 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_SESSION,
88 LTTNG_KERNEL_SESSION);
d65106b1
DG
89}
90
964ccb60
MD
91/* open the metadata global channel */
92int kernctl_open_metadata(int fd, struct lttng_channel_attr *chops)
f3ed775e 93{
4dbc372b
JD
94 struct lttng_kernel_channel channel;
95
96 if (lttng_kernel_use_old_abi) {
10600be0
MD
97 struct lttng_kernel_old_channel old_channel;
98
99 memset(&old_channel, 0, sizeof(old_channel));
4dbc372b
JD
100 old_channel.overwrite = chops->overwrite;
101 old_channel.subbuf_size = chops->subbuf_size;
102 old_channel.num_subbuf = chops->num_subbuf;
103 old_channel.switch_timer_interval = chops->switch_timer_interval;
104 old_channel.read_timer_interval = chops->read_timer_interval;
105 old_channel.output = chops->output;
f853c53a
DG
106
107 memset(old_channel.padding, 0, sizeof(old_channel.padding));
108 /*
109 * The new channel padding is smaller than the old ABI so we use the
110 * new ABI padding size for the memcpy.
111 */
112 memcpy(old_channel.padding, chops->padding, sizeof(chops->padding));
4dbc372b 113
5226f1bc
JG
114 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_OLD_METADATA,
115 &old_channel);
4dbc372b
JD
116 }
117
10600be0 118 memset(&channel, 0, sizeof(channel));
4dbc372b
JD
119 channel.overwrite = chops->overwrite;
120 channel.subbuf_size = chops->subbuf_size;
121 channel.num_subbuf = chops->num_subbuf;
122 channel.switch_timer_interval = chops->switch_timer_interval;
123 channel.read_timer_interval = chops->read_timer_interval;
124 channel.output = chops->output;
ea207e3b 125 memcpy(channel.padding, chops->padding, sizeof(chops->padding));
4dbc372b 126
5226f1bc 127 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_METADATA, &channel);
f3ed775e
DG
128}
129
130int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
16421f6e 131{
4dbc372b
JD
132 struct lttng_kernel_channel channel;
133
c74101ef 134 memset(&channel, 0, sizeof(channel));
4dbc372b
JD
135 if (lttng_kernel_use_old_abi) {
136 struct lttng_kernel_old_channel old_channel;
137
138 old_channel.overwrite = chops->overwrite;
139 old_channel.subbuf_size = chops->subbuf_size;
140 old_channel.num_subbuf = chops->num_subbuf;
141 old_channel.switch_timer_interval = chops->switch_timer_interval;
142 old_channel.read_timer_interval = chops->read_timer_interval;
143 old_channel.output = chops->output;
f853c53a
DG
144
145 memset(old_channel.padding, 0, sizeof(old_channel.padding));
146 /*
147 * The new channel padding is smaller than the old ABI so we use the
148 * new ABI padding size for the memcpy.
149 */
150 memcpy(old_channel.padding, chops->padding, sizeof(chops->padding));
4dbc372b 151
5226f1bc
JG
152 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_OLD_CHANNEL,
153 &old_channel);
4dbc372b
JD
154 }
155
156 channel.overwrite = chops->overwrite;
157 channel.subbuf_size = chops->subbuf_size;
158 channel.num_subbuf = chops->num_subbuf;
159 channel.switch_timer_interval = chops->switch_timer_interval;
160 channel.read_timer_interval = chops->read_timer_interval;
161 channel.output = chops->output;
ea207e3b 162 memcpy(channel.padding, chops->padding, sizeof(chops->padding));
4dbc372b 163
5226f1bc 164 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_CHANNEL, &channel);
16421f6e
DG
165}
166
46820c8b
MD
167int kernctl_syscall_mask(int fd, char **syscall_mask, uint32_t *nr_bits)
168{
169 struct lttng_kernel_syscall_mask kmask_len, *kmask = NULL;
170 size_t array_alloc_len;
171 char *new_mask;
172 int ret = 0;
173
174 if (!syscall_mask) {
175 ret = -1;
176 goto end;
177 }
178
179 if (!nr_bits) {
180 ret = -1;
181 goto end;
182 }
183
184 kmask_len.len = 0;
5226f1bc 185 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SYSCALL_MASK, &kmask_len);
46820c8b
MD
186 if (ret) {
187 goto end;
188 }
189
190 array_alloc_len = ALIGN(kmask_len.len, 8) >> 3;
834978fd 191
46820c8b
MD
192 kmask = zmalloc(sizeof(*kmask) + array_alloc_len);
193 if (!kmask) {
194 ret = -1;
195 goto end;
196 }
197
198 kmask->len = kmask_len.len;
5226f1bc 199 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SYSCALL_MASK, kmask);
46820c8b
MD
200 if (ret) {
201 goto end;
202 }
203
834978fd 204 new_mask = realloc(*syscall_mask, array_alloc_len);
46820c8b
MD
205 if (!new_mask) {
206 ret = -1;
207 goto end;
208 }
209 memcpy(new_mask, kmask->mask, array_alloc_len);
210 *syscall_mask = new_mask;
211 *nr_bits = kmask->len;
212
213end:
214 free(kmask);
215 return ret;
216}
217
ccf10263
MD
218int kernctl_track_pid(int fd, int pid)
219{
5226f1bc 220 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_TRACK_PID, pid);
ccf10263
MD
221}
222
223int kernctl_untrack_pid(int fd, int pid)
224{
5226f1bc 225 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_UNTRACK_PID, pid);
ccf10263
MD
226}
227
a5dfbb9d
MD
228int kernctl_list_tracker_pids(int fd)
229{
5226f1bc 230 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS);
a5dfbb9d
MD
231}
232
eded6438 233int kernctl_session_regenerate_metadata(int fd)
93ec662e 234{
5226f1bc 235 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_METADATA_REGEN);
93ec662e
JD
236}
237
c2561365
JD
238int kernctl_session_regenerate_statedump(int fd)
239{
240 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_STATEDUMP);
241}
242
8ff4109e
JR
243int kernctl_session_set_name(int fd, const char *name)
244{
245 int ret;
246 struct lttng_kernel_session_name session_name;
247
248 ret = lttng_strncpy(session_name.name, name, sizeof(session_name.name));
249 if (ret) {
250 goto end;
251 }
252
253 ret = LTTNG_IOCTL_CHECK(
254 fd, LTTNG_KERNEL_SESSION_SET_NAME, &session_name);
255end:
256 return ret;
257}
258
e04b2181
JR
259int kernctl_session_set_creation_time(int fd, time_t time)
260{
261 int ret;
262 struct lttng_kernel_session_creation_time creation_time;
263
264 ret = time_to_iso8601_str(time, creation_time.iso8601,
265 sizeof(creation_time.iso8601));
266 if (ret) {
267 goto end;
268 }
269
270 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_SESSION_SET_CREATION_TIME,
271 &creation_time);
272end:
273 return ret;
274}
275
964ccb60 276int kernctl_create_stream(int fd)
16421f6e 277{
4dbc372b
JD
278 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM,
279 LTTNG_KERNEL_STREAM);
16421f6e
DG
280}
281
964ccb60 282int kernctl_create_event(int fd, struct lttng_kernel_event *ev)
16421f6e 283{
4dbc372b
JD
284 if (lttng_kernel_use_old_abi) {
285 struct lttng_kernel_old_event old_event;
286
10600be0 287 memset(&old_event, 0, sizeof(old_event));
4dbc372b
JD
288 memcpy(old_event.name, ev->name, sizeof(old_event.name));
289 old_event.instrumentation = ev->instrumentation;
290 switch (ev->instrumentation) {
291 case LTTNG_KERNEL_KPROBE:
292 old_event.u.kprobe.addr = ev->u.kprobe.addr;
293 old_event.u.kprobe.offset = ev->u.kprobe.offset;
294 memcpy(old_event.u.kprobe.symbol_name,
295 ev->u.kprobe.symbol_name,
296 sizeof(old_event.u.kprobe.symbol_name));
297 break;
298 case LTTNG_KERNEL_KRETPROBE:
299 old_event.u.kretprobe.addr = ev->u.kretprobe.addr;
300 old_event.u.kretprobe.offset = ev->u.kretprobe.offset;
301 memcpy(old_event.u.kretprobe.symbol_name,
302 ev->u.kretprobe.symbol_name,
303 sizeof(old_event.u.kretprobe.symbol_name));
304 break;
305 case LTTNG_KERNEL_FUNCTION:
306 memcpy(old_event.u.ftrace.symbol_name,
307 ev->u.ftrace.symbol_name,
308 sizeof(old_event.u.ftrace.symbol_name));
309 break;
310 default:
311 break;
312 }
313
5226f1bc
JG
314 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_OLD_EVENT,
315 &old_event);
4dbc372b 316 }
5226f1bc 317 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_EVENT, ev);
16421f6e
DG
318}
319
964ccb60 320int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
16421f6e 321{
4dbc372b
JD
322 if (lttng_kernel_use_old_abi) {
323 struct lttng_kernel_old_context old_ctx;
324
10600be0 325 memset(&old_ctx, 0, sizeof(old_ctx));
4dbc372b
JD
326 old_ctx.ctx = ctx->ctx;
327 /* only type that uses the union */
aa3514e9 328 if (ctx->ctx == LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER) {
4dbc372b
JD
329 old_ctx.u.perf_counter.type =
330 ctx->u.perf_counter.type;
331 old_ctx.u.perf_counter.config =
332 ctx->u.perf_counter.config;
333 memcpy(old_ctx.u.perf_counter.name,
334 ctx->u.perf_counter.name,
335 sizeof(old_ctx.u.perf_counter.name));
336 }
5226f1bc 337 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_OLD_CONTEXT, &old_ctx);
4dbc372b 338 }
5226f1bc 339 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_CONTEXT, ctx);
16421f6e
DG
340}
341
964ccb60 342
5226f1bc 343/* Enable event, channel and session LTTNG_IOCTL_CHECK */
f3ed775e
DG
344int kernctl_enable(int fd)
345{
4dbc372b
JD
346 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_ENABLE,
347 LTTNG_KERNEL_ENABLE);
f3ed775e
DG
348}
349
5226f1bc 350/* Disable event, channel and session LTTNG_IOCTL_CHECK */
f3ed775e
DG
351int kernctl_disable(int fd)
352{
4dbc372b
JD
353 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_DISABLE,
354 LTTNG_KERNEL_DISABLE);
f3ed775e
DG
355}
356
964ccb60 357int kernctl_start_session(int fd)
16421f6e 358{
4dbc372b
JD
359 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_SESSION_START,
360 LTTNG_KERNEL_SESSION_START);
964ccb60
MD
361}
362
363int kernctl_stop_session(int fd)
364{
4dbc372b
JD
365 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_SESSION_STOP,
366 LTTNG_KERNEL_SESSION_STOP);
16421f6e
DG
367}
368
00a62084
MD
369int kernctl_filter(int fd, struct lttng_filter_bytecode *filter)
370{
371 struct lttng_kernel_filter_bytecode *kb;
372 uint32_t len;
373 int ret;
374
375 /* Translate bytecode to kernel bytecode */
376 kb = zmalloc(sizeof(*kb) + filter->len);
377 if (!kb)
378 return -ENOMEM;
379 kb->len = len = filter->len;
380 kb->reloc_offset = filter->reloc_table_offset;
381 kb->seqnum = filter->seqnum;
382 memcpy(kb->data, filter->data, len);
5226f1bc 383 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_FILTER, kb);
00a62084
MD
384 free(kb);
385 return ret;
386}
387
1ab8c2ad
FD
388int kernctl_add_callsite(int fd, struct lttng_kernel_event_callsite *callsite)
389{
390 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_ADD_CALLSITE, callsite);
391}
392
964ccb60
MD
393int kernctl_tracepoint_list(int fd)
394{
4dbc372b
JD
395 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_TRACEPOINT_LIST,
396 LTTNG_KERNEL_TRACEPOINT_LIST);
964ccb60
MD
397}
398
d02666a9
MD
399int kernctl_syscall_list(int fd)
400{
5226f1bc 401 return LTTNG_IOCTL_NO_CHECK(fd, LTTNG_KERNEL_SYSCALL_LIST);
d02666a9
MD
402}
403
964ccb60
MD
404int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
405{
4dbc372b
JD
406 int ret;
407
408 if (lttng_kernel_use_old_abi == -1) {
5226f1bc 409 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_TRACER_VERSION, v);
4dbc372b
JD
410 if (!ret) {
411 lttng_kernel_use_old_abi = 0;
412 goto end;
413 }
414 lttng_kernel_use_old_abi = 1;
415 }
416 if (lttng_kernel_use_old_abi) {
417 struct lttng_kernel_old_tracer_version old_v;
418
5226f1bc 419 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_OLD_TRACER_VERSION, &old_v);
4dbc372b
JD
420 if (ret) {
421 goto end;
422 }
423 v->major = old_v.major;
424 v->minor = old_v.minor;
425 v->patchlevel = old_v.patchlevel;
426 } else {
5226f1bc 427 ret = LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_TRACER_VERSION, v);
4dbc372b
JD
428 }
429
430end:
431 return ret;
964ccb60
MD
432}
433
c052142c
MD
434int kernctl_tracer_abi_version(int fd,
435 struct lttng_kernel_tracer_abi_version *v)
436{
5226f1bc 437 return LTTNG_IOCTL_CHECK(fd, LTTNG_KERNEL_TRACER_ABI_VERSION, v);
c052142c
MD
438}
439
964ccb60
MD
440int kernctl_wait_quiescent(int fd)
441{
4dbc372b
JD
442 return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_WAIT_QUIESCENT,
443 LTTNG_KERNEL_WAIT_QUIESCENT);
964ccb60
MD
444}
445
964ccb60
MD
446int kernctl_buffer_flush(int fd)
447{
5226f1bc 448 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_FLUSH);
964ccb60
MD
449}
450
f22dd891
MD
451int kernctl_buffer_flush_empty(int fd)
452{
453 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_FLUSH_EMPTY);
454}
455
99930a9d
JR
456int kernctl_buffer_clear(int fd)
457{
458 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_CLEAR);
459}
460
93ec662e
JD
461/* returns the version of the metadata. */
462int kernctl_get_metadata_version(int fd, uint64_t *version)
463{
5226f1bc 464 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_METADATA_VERSION, version);
93ec662e
JD
465}
466
8024cc8c
JD
467int kernctl_metadata_cache_dump(int fd)
468{
469 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_METADATA_CACHE_DUMP);
470}
964ccb60
MD
471
472/* Buffer operations */
473
474/* For mmap mode, readable without "get" operation */
475
16421f6e
DG
476/* returns the length to mmap. */
477int kernctl_get_mmap_len(int fd, unsigned long *len)
478{
5226f1bc 479 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_MMAP_LEN, len);
16421f6e
DG
480}
481
964ccb60
MD
482/* returns the maximum size for sub-buffers. */
483int kernctl_get_max_subbuf_size(int fd, unsigned long *len)
484{
5226f1bc 485 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_MAX_SUBBUF_SIZE, len);
964ccb60
MD
486}
487
488/*
489 * For mmap mode, operate on the current packet (between get/put or
490 * get_next/put_next).
491 */
492
16421f6e
DG
493/* returns the offset of the subbuffer belonging to the mmap reader. */
494int kernctl_get_mmap_read_offset(int fd, unsigned long *off)
495{
5226f1bc 496 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_MMAP_READ_OFFSET, off);
16421f6e
DG
497}
498
964ccb60
MD
499/* returns the size of the current sub-buffer, without padding (for mmap). */
500int kernctl_get_subbuf_size(int fd, unsigned long *len)
16421f6e 501{
5226f1bc 502 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_SUBBUF_SIZE, len);
16421f6e
DG
503}
504
505/* returns the size of the current sub-buffer, without padding (for mmap). */
506int kernctl_get_padded_subbuf_size(int fd, unsigned long *len)
507{
5226f1bc 508 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_PADDED_SUBBUF_SIZE, len);
16421f6e
DG
509}
510
964ccb60
MD
511/* Get exclusive read access to the next sub-buffer that can be read. */
512int kernctl_get_next_subbuf(int fd)
16421f6e 513{
5226f1bc 514 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_NEXT_SUBBUF);
16421f6e
DG
515}
516
d4a1283e 517
16421f6e
DG
518/* Release exclusive sub-buffer access, move consumer forward. */
519int kernctl_put_next_subbuf(int fd)
520{
5226f1bc 521 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_PUT_NEXT_SUBBUF);
16421f6e
DG
522}
523
964ccb60 524/* snapshot */
16421f6e
DG
525
526/* Get a snapshot of the current ring buffer producer and consumer positions */
527int kernctl_snapshot(int fd)
528{
5226f1bc 529 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_SNAPSHOT);
16421f6e
DG
530}
531
b007ec59
JG
532/*
533 * Get a snapshot of the current ring buffer producer and consumer positions,
534 * regardless of whether or not the two positions are contained within the
535 * same sub-buffer.
536 */
537int kernctl_snapshot_sample_positions(int fd)
538{
539 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS);
540}
541
16421f6e
DG
542/* Get the consumer position (iteration start) */
543int kernctl_snapshot_get_consumed(int fd, unsigned long *pos)
544{
5226f1bc 545 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_SNAPSHOT_GET_CONSUMED, pos);
16421f6e
DG
546}
547
548/* Get the producer position (iteration end) */
549int kernctl_snapshot_get_produced(int fd, unsigned long *pos)
550{
5226f1bc 551 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_SNAPSHOT_GET_PRODUCED, pos);
16421f6e
DG
552}
553
964ccb60
MD
554/* Get exclusive read access to the specified sub-buffer position */
555int kernctl_get_subbuf(int fd, unsigned long *len)
f3ed775e 556{
5226f1bc 557 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_GET_SUBBUF, len);
f3ed775e 558}
d0254c7c 559
964ccb60
MD
560/* Release exclusive sub-buffer access */
561int kernctl_put_subbuf(int fd)
d0254c7c 562{
5226f1bc 563 return LTTNG_IOCTL_CHECK(fd, RING_BUFFER_PUT_SUBBUF);
d0254c7c 564}
309167d2
JD
565
566/* Returns the timestamp begin of the current sub-buffer. */
567int kernctl_get_timestamp_begin(int fd, uint64_t *timestamp_begin)
568{
5226f1bc 569 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN,
a6bd6d9b 570 timestamp_begin);
309167d2
JD
571}
572
573/* Returns the timestamp end of the current sub-buffer. */
574int kernctl_get_timestamp_end(int fd, uint64_t *timestamp_end)
575{
5226f1bc 576 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_TIMESTAMP_END,
a6bd6d9b 577 timestamp_end);
309167d2
JD
578}
579
580/* Returns the number of discarded events in the current sub-buffer. */
581int kernctl_get_events_discarded(int fd, uint64_t *events_discarded)
582{
5226f1bc 583 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED,
a6bd6d9b 584 events_discarded);
309167d2
JD
585}
586
587/* Returns the content size in the current sub-buffer. */
588int kernctl_get_content_size(int fd, uint64_t *content_size)
589{
5226f1bc 590 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_CONTENT_SIZE,
a6bd6d9b 591 content_size);
309167d2
JD
592}
593
594/* Returns the packet size in the current sub-buffer. */
595int kernctl_get_packet_size(int fd, uint64_t *packet_size)
596{
5226f1bc
JG
597 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_PACKET_SIZE,
598 packet_size);
309167d2
JD
599}
600
601/* Returns the stream id of the current sub-buffer. */
602int kernctl_get_stream_id(int fd, uint64_t *stream_id)
603{
5226f1bc
JG
604 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_STREAM_ID,
605 stream_id);
309167d2 606}
d3e2ba59
JD
607
608/* Returns the current timestamp. */
609int kernctl_get_current_timestamp(int fd, uint64_t *ts)
610{
5226f1bc
JG
611 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP,
612 ts);
d3e2ba59 613}
fb83fe64
JD
614
615/* Returns the packet sequence number of the current sub-buffer. */
616int kernctl_get_sequence_number(int fd, uint64_t *seq)
617{
5226f1bc 618 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_GET_SEQ_NUM, seq);
fb83fe64 619}
000fa86f
JD
620
621/* Returns the stream instance id. */
622int kernctl_get_instance_id(int fd, uint64_t *id)
623{
5226f1bc 624 return LTTNG_IOCTL_CHECK(fd, LTTNG_RING_BUFFER_INSTANCE_ID, id);
000fa86f 625}
This page took 0.135211 seconds and 4 git commands to generate.