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