kernctl commands to extract the stream instance id
[lttng-tools.git] / src / common / kernel-ctl / kernel-ctl.c
index 51d01341338441bc3faffbf5f3d9fb5c52b29486..dd228773bc655eb985e88a6b2fe20e8c87221115 100644 (file)
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _GNU_SOURCE
 #define _LGPL_SOURCE
 #define __USE_LINUX_IOCTL_DEFS
 #include <sys/ioctl.h>
 #include <string.h>
 #include <common/align.h>
+#include <errno.h>
 
 #include "kernel-ctl.h"
 #include "kernel-ioctl.h"
@@ -111,6 +111,7 @@ int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
 {
        struct lttng_kernel_channel channel;
 
+       memset(&channel, 0, sizeof(channel));
        if (lttng_kernel_use_old_abi) {
                struct lttng_kernel_old_channel old_channel;
 
@@ -298,6 +299,25 @@ int kernctl_stop_session(int fd)
                        LTTNG_KERNEL_SESSION_STOP);
 }
 
+int kernctl_filter(int fd, struct lttng_filter_bytecode *filter)
+{
+       struct lttng_kernel_filter_bytecode *kb;
+       uint32_t len;
+       int ret;
+
+       /* Translate bytecode to kernel bytecode */
+       kb = zmalloc(sizeof(*kb) + filter->len);
+       if (!kb)
+               return -ENOMEM;
+       kb->len = len = filter->len;
+       kb->reloc_offset = filter->reloc_table_offset;
+       kb->seqnum = filter->seqnum;
+       memcpy(kb->data, filter->data, len);
+       ret = ioctl(fd, LTTNG_KERNEL_FILTER, kb);
+       free(kb);
+       return ret;
+}
+
 int kernctl_tracepoint_list(int fd)
 {
        return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_TRACEPOINT_LIST,
@@ -512,3 +532,15 @@ int kernctl_get_current_timestamp(int fd, uint64_t *ts)
 {
        return ioctl(fd, LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP, ts);
 }
+
+/* Returns the packet sequence number of the current sub-buffer. */
+int kernctl_get_sequence_number(int fd, uint64_t *seq)
+{
+       return ioctl(fd, LTTNG_RING_BUFFER_GET_SEQ_NUM, seq);
+}
+
+/* Returns the stream instance id. */
+int kernctl_get_instance_id(int fd, uint64_t *id)
+{
+       return ioctl(fd, LTTNG_RING_BUFFER_INSTANCE_ID, id);
+}
This page took 0.024258 seconds and 4 git commands to generate.