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>
6 * SPDX-License-Identifier: GPL-2.0-only
10 #include "lttng/tracker.h"
12 #define __USE_LINUX_IOCTL_DEFS
13 #include <sys/ioctl.h>
15 #include <common/align.h>
16 #include <common/macros.h>
17 #include <common/compat/errno.h>
20 #include <common/time.h>
22 #include "kernel-ctl.h"
23 #include "kernel-ioctl.h"
25 #define LTTNG_IOCTL_CHECK(fildes, request, ...) ({ \
26 int ret = ioctl(fildes, request, ##__VA_ARGS__);\
31 #define LTTNG_IOCTL_NO_CHECK(fildes, request, ...) ({ \
32 int ret = ioctl(fildes, request, ##__VA_ARGS__);\
33 ret >= 0 ? ret : -errno; \
37 * This flag indicates which version of the kernel ABI to use. The old
38 * ABI (namespace _old) does not support a 32-bit user-space when the
39 * kernel is 64-bit. The old ABI is kept here for compatibility but is
40 * deprecated and will be removed eventually.
42 static int lttng_kernel_use_old_abi
= -1;
45 * Execute the new or old ioctl depending on the ABI version.
46 * If the ABI version is not determined yet (lttng_kernel_use_old_abi = -1),
47 * this function tests if the new ABI is available and otherwise fallbacks
49 * This function takes the fd on which the ioctl must be executed and the old
50 * and new request codes.
51 * It returns the return value of the ioctl executed.
53 static inline int compat_ioctl_no_arg(int fd
, unsigned long oldname
,
54 unsigned long newname
)
58 if (lttng_kernel_use_old_abi
== -1) {
59 ret
= LTTNG_IOCTL_NO_CHECK(fd
, newname
);
61 lttng_kernel_use_old_abi
= 0;
64 lttng_kernel_use_old_abi
= 1;
66 if (lttng_kernel_use_old_abi
) {
67 ret
= LTTNG_IOCTL_NO_CHECK(fd
, oldname
);
69 ret
= LTTNG_IOCTL_NO_CHECK(fd
, newname
);
76 int kernctl_create_session(int fd
)
78 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_SESSION
,
79 LTTNG_KERNEL_SESSION
);
82 /* open the metadata global channel */
83 int kernctl_open_metadata(int fd
, struct lttng_channel_attr
*chops
)
85 struct lttng_kernel_channel channel
;
87 if (lttng_kernel_use_old_abi
) {
88 struct lttng_kernel_old_channel old_channel
;
90 memset(&old_channel
, 0, sizeof(old_channel
));
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
;
98 memset(old_channel
.padding
, 0, sizeof(old_channel
.padding
));
100 * The new channel padding is smaller than the old ABI so we use the
101 * new ABI padding size for the memcpy.
103 memcpy(old_channel
.padding
, chops
->padding
, sizeof(chops
->padding
));
105 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_OLD_METADATA
,
109 memset(&channel
, 0, sizeof(channel
));
110 channel
.overwrite
= chops
->overwrite
;
111 channel
.subbuf_size
= chops
->subbuf_size
;
112 channel
.num_subbuf
= chops
->num_subbuf
;
113 channel
.switch_timer_interval
= chops
->switch_timer_interval
;
114 channel
.read_timer_interval
= chops
->read_timer_interval
;
115 channel
.output
= chops
->output
;
116 memcpy(channel
.padding
, chops
->padding
, sizeof(chops
->padding
));
118 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_METADATA
, &channel
);
121 int kernctl_create_channel(int fd
, struct lttng_channel_attr
*chops
)
123 struct lttng_kernel_channel channel
;
125 memset(&channel
, 0, sizeof(channel
));
126 if (lttng_kernel_use_old_abi
) {
127 struct lttng_kernel_old_channel old_channel
;
129 old_channel
.overwrite
= chops
->overwrite
;
130 old_channel
.subbuf_size
= chops
->subbuf_size
;
131 old_channel
.num_subbuf
= chops
->num_subbuf
;
132 old_channel
.switch_timer_interval
= chops
->switch_timer_interval
;
133 old_channel
.read_timer_interval
= chops
->read_timer_interval
;
134 old_channel
.output
= chops
->output
;
136 memset(old_channel
.padding
, 0, sizeof(old_channel
.padding
));
138 * The new channel padding is smaller than the old ABI so we use the
139 * new ABI padding size for the memcpy.
141 memcpy(old_channel
.padding
, chops
->padding
, sizeof(chops
->padding
));
143 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_OLD_CHANNEL
,
147 channel
.overwrite
= chops
->overwrite
;
148 channel
.subbuf_size
= chops
->subbuf_size
;
149 channel
.num_subbuf
= chops
->num_subbuf
;
150 channel
.switch_timer_interval
= chops
->switch_timer_interval
;
151 channel
.read_timer_interval
= chops
->read_timer_interval
;
152 channel
.output
= chops
->output
;
153 memcpy(channel
.padding
, chops
->padding
, sizeof(chops
->padding
));
155 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_CHANNEL
, &channel
);
158 int kernctl_syscall_mask(int fd
, char **syscall_mask
, uint32_t *nr_bits
)
160 struct lttng_kernel_syscall_mask kmask_len
, *kmask
= NULL
;
161 size_t array_alloc_len
;
176 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SYSCALL_MASK
, &kmask_len
);
181 array_alloc_len
= ALIGN(kmask_len
.len
, 8) >> 3;
183 kmask
= zmalloc(sizeof(*kmask
) + array_alloc_len
);
189 kmask
->len
= kmask_len
.len
;
190 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SYSCALL_MASK
, kmask
);
195 new_mask
= realloc(*syscall_mask
, array_alloc_len
);
200 memcpy(new_mask
, kmask
->mask
, array_alloc_len
);
201 *syscall_mask
= new_mask
;
202 *nr_bits
= kmask
->len
;
209 int kernctl_track_pid(int fd
, int pid
)
211 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_TRACK_PID
, pid
);
214 int kernctl_untrack_pid(int fd
, int pid
)
216 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_UNTRACK_PID
, pid
);
219 int kernctl_list_tracker_pids(int fd
)
221 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS
);
224 static enum lttng_kernel_tracker_type
get_kernel_tracker_type(
225 enum lttng_process_attr process_attr
)
227 switch (process_attr
) {
228 case LTTNG_PROCESS_ATTR_PROCESS_ID
:
229 return LTTNG_KERNEL_TRACKER_PID
;
230 case LTTNG_PROCESS_ATTR_VIRTUAL_PROCESS_ID
:
231 return LTTNG_KERNEL_TRACKER_VPID
;
232 case LTTNG_PROCESS_ATTR_USER_ID
:
233 return LTTNG_KERNEL_TRACKER_UID
;
234 case LTTNG_PROCESS_ATTR_VIRTUAL_USER_ID
:
235 return LTTNG_KERNEL_TRACKER_VUID
;
236 case LTTNG_PROCESS_ATTR_GROUP_ID
:
237 return LTTNG_KERNEL_TRACKER_GID
;
238 case LTTNG_PROCESS_ATTR_VIRTUAL_GROUP_ID
:
239 return LTTNG_KERNEL_TRACKER_VGID
;
241 return LTTNG_KERNEL_TRACKER_UNKNOWN
;
245 int kernctl_track_id(int fd
, enum lttng_process_attr process_attr
, int id
)
247 struct lttng_kernel_tracker_args args
;
250 args
.type
= get_kernel_tracker_type(process_attr
);
251 if (args
.type
== LTTNG_KERNEL_TRACKER_UNKNOWN
) {
255 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_TRACK_ID
, &args
);
258 int kernctl_untrack_id(int fd
, enum lttng_process_attr process_attr
, int id
)
260 struct lttng_kernel_tracker_args args
;
263 args
.type
= get_kernel_tracker_type(process_attr
);
264 if (args
.type
== LTTNG_KERNEL_TRACKER_UNKNOWN
) {
268 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_UNTRACK_ID
, &args
);
271 int kernctl_list_tracker_ids(int fd
, enum lttng_process_attr process_attr
)
273 struct lttng_kernel_tracker_args args
;
276 args
.type
= get_kernel_tracker_type(process_attr
);
277 if (args
.type
== LTTNG_KERNEL_TRACKER_UNKNOWN
) {
281 return LTTNG_IOCTL_NO_CHECK(
282 fd
, LTTNG_KERNEL_SESSION_LIST_TRACKER_IDS
, &args
);
285 int kernctl_session_regenerate_metadata(int fd
)
287 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_METADATA_REGEN
);
290 int kernctl_session_regenerate_statedump(int fd
)
292 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_STATEDUMP
);
295 int kernctl_session_set_name(int fd
, const char *name
)
298 struct lttng_kernel_session_name session_name
;
300 ret
= lttng_strncpy(session_name
.name
, name
, sizeof(session_name
.name
));
305 ret
= LTTNG_IOCTL_CHECK(
306 fd
, LTTNG_KERNEL_SESSION_SET_NAME
, &session_name
);
311 int kernctl_session_set_creation_time(int fd
, time_t time
)
314 struct lttng_kernel_session_creation_time creation_time
;
316 ret
= time_to_iso8601_str(time
, creation_time
.iso8601
,
317 sizeof(creation_time
.iso8601
));
322 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_SESSION_SET_CREATION_TIME
,
328 int kernctl_create_stream(int fd
)
330 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_STREAM
,
331 LTTNG_KERNEL_STREAM
);
334 int kernctl_create_event(int fd
, struct lttng_kernel_event
*ev
)
336 if (lttng_kernel_use_old_abi
) {
337 struct lttng_kernel_old_event old_event
;
339 memset(&old_event
, 0, sizeof(old_event
));
340 memcpy(old_event
.name
, ev
->name
, sizeof(old_event
.name
));
341 old_event
.instrumentation
= ev
->instrumentation
;
342 switch (ev
->instrumentation
) {
343 case LTTNG_KERNEL_KPROBE
:
344 old_event
.u
.kprobe
.addr
= ev
->u
.kprobe
.addr
;
345 old_event
.u
.kprobe
.offset
= ev
->u
.kprobe
.offset
;
346 memcpy(old_event
.u
.kprobe
.symbol_name
,
347 ev
->u
.kprobe
.symbol_name
,
348 sizeof(old_event
.u
.kprobe
.symbol_name
));
350 case LTTNG_KERNEL_KRETPROBE
:
351 old_event
.u
.kretprobe
.addr
= ev
->u
.kretprobe
.addr
;
352 old_event
.u
.kretprobe
.offset
= ev
->u
.kretprobe
.offset
;
353 memcpy(old_event
.u
.kretprobe
.symbol_name
,
354 ev
->u
.kretprobe
.symbol_name
,
355 sizeof(old_event
.u
.kretprobe
.symbol_name
));
357 case LTTNG_KERNEL_FUNCTION
:
358 memcpy(old_event
.u
.ftrace
.symbol_name
,
359 ev
->u
.ftrace
.symbol_name
,
360 sizeof(old_event
.u
.ftrace
.symbol_name
));
366 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_OLD_EVENT
,
369 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_EVENT
, ev
);
372 int kernctl_add_context(int fd
, struct lttng_kernel_context
*ctx
)
374 if (lttng_kernel_use_old_abi
) {
375 struct lttng_kernel_old_context old_ctx
;
377 memset(&old_ctx
, 0, sizeof(old_ctx
));
378 old_ctx
.ctx
= ctx
->ctx
;
379 /* only type that uses the union */
380 if (ctx
->ctx
== LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER
) {
381 old_ctx
.u
.perf_counter
.type
=
382 ctx
->u
.perf_counter
.type
;
383 old_ctx
.u
.perf_counter
.config
=
384 ctx
->u
.perf_counter
.config
;
385 memcpy(old_ctx
.u
.perf_counter
.name
,
386 ctx
->u
.perf_counter
.name
,
387 sizeof(old_ctx
.u
.perf_counter
.name
));
389 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_OLD_CONTEXT
, &old_ctx
);
391 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_CONTEXT
, ctx
);
395 /* Enable event, channel and session LTTNG_IOCTL_CHECK */
396 int kernctl_enable(int fd
)
398 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_ENABLE
,
399 LTTNG_KERNEL_ENABLE
);
402 /* Disable event, channel and session LTTNG_IOCTL_CHECK */
403 int kernctl_disable(int fd
)
405 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_DISABLE
,
406 LTTNG_KERNEL_DISABLE
);
409 int kernctl_start_session(int fd
)
411 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_SESSION_START
,
412 LTTNG_KERNEL_SESSION_START
);
415 int kernctl_stop_session(int fd
)
417 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_SESSION_STOP
,
418 LTTNG_KERNEL_SESSION_STOP
);
421 int kernctl_create_event_notifier_group(int fd
)
423 return LTTNG_IOCTL_NO_CHECK(fd
,
424 LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_CREATE
);
427 int kernctl_create_event_notifier_group_notification_fd(int group_fd
)
429 return LTTNG_IOCTL_NO_CHECK(group_fd
,
430 LTTNG_KERNEL_EVENT_NOTIFIER_GROUP_NOTIFICATION_FD
);
433 int kernctl_create_event_notifier(int group_fd
,
434 const struct lttng_kernel_event_notifier
*event_notifier
)
436 return LTTNG_IOCTL_NO_CHECK(group_fd
,
437 LTTNG_KERNEL_EVENT_NOTIFIER_CREATE
, event_notifier
);
440 int kernctl_capture(int fd
, const struct lttng_bytecode
*capture
)
443 struct lttng_kernel_capture_bytecode
*kb
;
445 /* Translate bytecode to kernel bytecode. */
446 kb
= zmalloc(sizeof(*kb
) + capture
->len
);
452 kb
->len
= capture
->len
;
453 kb
->reloc_offset
= capture
->reloc_table_offset
;
454 kb
->seqnum
= capture
->seqnum
;
455 memcpy(kb
->data
, capture
->data
, capture
->len
);
456 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_CAPTURE
, kb
);
462 int kernctl_filter(int fd
, const struct lttng_bytecode
*filter
)
464 struct lttng_kernel_filter_bytecode
*kb
;
468 /* Translate bytecode to kernel bytecode */
469 kb
= zmalloc(sizeof(*kb
) + filter
->len
);
472 kb
->len
= len
= filter
->len
;
473 kb
->reloc_offset
= filter
->reloc_table_offset
;
474 kb
->seqnum
= filter
->seqnum
;
475 memcpy(kb
->data
, filter
->data
, len
);
476 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_FILTER
, kb
);
481 int kernctl_add_callsite(int fd
, struct lttng_kernel_event_callsite
*callsite
)
483 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_ADD_CALLSITE
, callsite
);
486 int kernctl_tracepoint_list(int fd
)
488 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_TRACEPOINT_LIST
,
489 LTTNG_KERNEL_TRACEPOINT_LIST
);
492 int kernctl_syscall_list(int fd
)
494 return LTTNG_IOCTL_NO_CHECK(fd
, LTTNG_KERNEL_SYSCALL_LIST
);
497 int kernctl_tracer_version(int fd
, struct lttng_kernel_tracer_version
*v
)
501 if (lttng_kernel_use_old_abi
== -1) {
502 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_TRACER_VERSION
, v
);
504 lttng_kernel_use_old_abi
= 0;
507 lttng_kernel_use_old_abi
= 1;
509 if (lttng_kernel_use_old_abi
) {
510 struct lttng_kernel_old_tracer_version old_v
;
512 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_OLD_TRACER_VERSION
, &old_v
);
516 v
->major
= old_v
.major
;
517 v
->minor
= old_v
.minor
;
518 v
->patchlevel
= old_v
.patchlevel
;
520 ret
= LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_TRACER_VERSION
, v
);
527 int kernctl_tracer_abi_version(int fd
,
528 struct lttng_kernel_tracer_abi_version
*v
)
530 return LTTNG_IOCTL_CHECK(fd
, LTTNG_KERNEL_TRACER_ABI_VERSION
, v
);
533 int kernctl_wait_quiescent(int fd
)
535 return compat_ioctl_no_arg(fd
, LTTNG_KERNEL_OLD_WAIT_QUIESCENT
,
536 LTTNG_KERNEL_WAIT_QUIESCENT
);
539 int kernctl_buffer_flush(int fd
)
541 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_FLUSH
);
544 int kernctl_buffer_flush_empty(int fd
)
546 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_FLUSH_EMPTY
);
549 int kernctl_buffer_clear(int fd
)
551 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_CLEAR
);
554 int kernctl_get_next_subbuf_metadata_check(int fd
, bool *consistent
)
556 return LTTNG_IOCTL_NO_CHECK(fd
,
557 RING_RING_BUFFER_GET_NEXT_SUBBUF_METADATA_CHECK
,
561 /* returns the version of the metadata. */
562 int kernctl_get_metadata_version(int fd
, uint64_t *version
)
564 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_METADATA_VERSION
, version
);
567 int kernctl_metadata_cache_dump(int fd
)
569 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_METADATA_CACHE_DUMP
);
572 /* Buffer operations */
574 /* For mmap mode, readable without "get" operation */
576 /* returns the length to mmap. */
577 int kernctl_get_mmap_len(int fd
, unsigned long *len
)
579 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_MMAP_LEN
, len
);
582 /* returns the maximum size for sub-buffers. */
583 int kernctl_get_max_subbuf_size(int fd
, unsigned long *len
)
585 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_MAX_SUBBUF_SIZE
, len
);
589 * For mmap mode, operate on the current packet (between get/put or
590 * get_next/put_next).
593 /* returns the offset of the subbuffer belonging to the mmap reader. */
594 int kernctl_get_mmap_read_offset(int fd
, unsigned long *off
)
596 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_MMAP_READ_OFFSET
, off
);
599 /* returns the size of the current sub-buffer, without padding (for mmap). */
600 int kernctl_get_subbuf_size(int fd
, unsigned long *len
)
602 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_SUBBUF_SIZE
, len
);
605 /* returns the size of the current sub-buffer, without padding (for mmap). */
606 int kernctl_get_padded_subbuf_size(int fd
, unsigned long *len
)
608 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_PADDED_SUBBUF_SIZE
, len
);
611 /* Get exclusive read access to the next sub-buffer that can be read. */
612 int kernctl_get_next_subbuf(int fd
)
614 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_NEXT_SUBBUF
);
618 /* Release exclusive sub-buffer access, move consumer forward. */
619 int kernctl_put_next_subbuf(int fd
)
621 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_PUT_NEXT_SUBBUF
);
626 /* Get a snapshot of the current ring buffer producer and consumer positions */
627 int kernctl_snapshot(int fd
)
629 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_SNAPSHOT
);
633 * Get a snapshot of the current ring buffer producer and consumer positions,
634 * regardless of whether or not the two positions are contained within the
637 int kernctl_snapshot_sample_positions(int fd
)
639 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_SNAPSHOT_SAMPLE_POSITIONS
);
642 /* Get the consumer position (iteration start) */
643 int kernctl_snapshot_get_consumed(int fd
, unsigned long *pos
)
645 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_SNAPSHOT_GET_CONSUMED
, pos
);
648 /* Get the producer position (iteration end) */
649 int kernctl_snapshot_get_produced(int fd
, unsigned long *pos
)
651 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_SNAPSHOT_GET_PRODUCED
, pos
);
654 /* Get exclusive read access to the specified sub-buffer position */
655 int kernctl_get_subbuf(int fd
, unsigned long *len
)
657 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_GET_SUBBUF
, len
);
660 /* Release exclusive sub-buffer access */
661 int kernctl_put_subbuf(int fd
)
663 return LTTNG_IOCTL_CHECK(fd
, RING_BUFFER_PUT_SUBBUF
);
666 /* Returns the timestamp begin of the current sub-buffer. */
667 int kernctl_get_timestamp_begin(int fd
, uint64_t *timestamp_begin
)
669 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_TIMESTAMP_BEGIN
,
673 /* Returns the timestamp end of the current sub-buffer. */
674 int kernctl_get_timestamp_end(int fd
, uint64_t *timestamp_end
)
676 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_TIMESTAMP_END
,
680 /* Returns the number of discarded events in the current sub-buffer. */
681 int kernctl_get_events_discarded(int fd
, uint64_t *events_discarded
)
683 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_EVENTS_DISCARDED
,
687 /* Returns the content size in the current sub-buffer. */
688 int kernctl_get_content_size(int fd
, uint64_t *content_size
)
690 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_CONTENT_SIZE
,
694 /* Returns the packet size in the current sub-buffer. */
695 int kernctl_get_packet_size(int fd
, uint64_t *packet_size
)
697 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_PACKET_SIZE
,
701 /* Returns the stream id of the current sub-buffer. */
702 int kernctl_get_stream_id(int fd
, uint64_t *stream_id
)
704 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_STREAM_ID
,
708 /* Returns the current timestamp. */
709 int kernctl_get_current_timestamp(int fd
, uint64_t *ts
)
711 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP
,
715 /* Returns the packet sequence number of the current sub-buffer. */
716 int kernctl_get_sequence_number(int fd
, uint64_t *seq
)
718 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_GET_SEQ_NUM
, seq
);
721 /* Returns the stream instance id. */
722 int kernctl_get_instance_id(int fd
, uint64_t *id
)
724 return LTTNG_IOCTL_CHECK(fd
, LTTNG_RING_BUFFER_INSTANCE_ID
, id
);