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