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