Support lttng-modules syscall wildcards
[lttng-tools.git] / src / common / kernel-ctl / kernel-ctl.c
index 495301e5ff362cc85d9748fa4ad0ee60938b0490..51d01341338441bc3faffbf5f3d9fb5c52b29486 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 "kernel-ctl.h"
 #include "kernel-ioctl.h"
@@ -139,6 +142,72 @@ int kernctl_create_channel(int fd, struct lttng_channel_attr *chops)
        return ioctl(fd, LTTNG_KERNEL_CHANNEL, &channel);
 }
 
+int kernctl_syscall_mask(int fd, char **syscall_mask, uint32_t *nr_bits)
+{
+       struct lttng_kernel_syscall_mask kmask_len, *kmask = NULL;
+       size_t array_alloc_len;
+       char *new_mask;
+       int ret = 0;
+
+       if (!syscall_mask) {
+               ret = -1;
+               goto end;
+       }
+
+       if (!nr_bits) {
+               ret = -1;
+               goto end;
+       }
+
+       kmask_len.len = 0;
+       ret = ioctl(fd, LTTNG_KERNEL_SYSCALL_MASK, &kmask_len);
+       if (ret) {
+               goto end;
+       }
+
+       array_alloc_len = ALIGN(kmask_len.len, 8) >> 3;
+
+       kmask = zmalloc(sizeof(*kmask) + array_alloc_len);
+       if (!kmask) {
+               ret = -1;
+               goto end;
+       }
+
+       kmask->len = kmask_len.len;
+       ret = ioctl(fd, LTTNG_KERNEL_SYSCALL_MASK, kmask);
+       if (ret) {
+               goto end;
+       }
+
+       new_mask = realloc(*syscall_mask, array_alloc_len);
+       if (!new_mask) {
+               ret = -1;
+               goto end;
+       }
+       memcpy(new_mask, kmask->mask, array_alloc_len);
+       *syscall_mask = new_mask;
+       *nr_bits = kmask->len;
+
+end:
+       free(kmask);
+       return ret;
+}
+
+int kernctl_track_pid(int fd, int pid)
+{
+       return ioctl(fd, LTTNG_KERNEL_SESSION_TRACK_PID, pid);
+}
+
+int kernctl_untrack_pid(int fd, int pid)
+{
+       return ioctl(fd, LTTNG_KERNEL_SESSION_UNTRACK_PID, pid);
+}
+
+int kernctl_list_tracker_pids(int fd)
+{
+       return ioctl(fd, LTTNG_KERNEL_SESSION_LIST_TRACKER_PIDS);
+}
+
 int kernctl_create_stream(int fd)
 {
        return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_STREAM,
@@ -188,7 +257,7 @@ int kernctl_add_context(int fd, struct lttng_kernel_context *ctx)
 
                old_ctx.ctx = ctx->ctx;
                /* only type that uses the union */
-               if (ctx->ctx == LTTNG_KERNEL_CONTEXT_PERF_COUNTER) {
+               if (ctx->ctx == LTTNG_KERNEL_CONTEXT_PERF_CPU_COUNTER) {
                        old_ctx.u.perf_counter.type =
                                ctx->u.perf_counter.type;
                        old_ctx.u.perf_counter.config =
@@ -235,6 +304,11 @@ int kernctl_tracepoint_list(int fd)
                        LTTNG_KERNEL_TRACEPOINT_LIST);
 }
 
+int kernctl_syscall_list(int fd)
+{
+       return ioctl(fd, LTTNG_KERNEL_SYSCALL_LIST);
+}
+
 int kernctl_tracer_version(int fd, struct lttng_kernel_tracer_version *v)
 {
        int ret;
@@ -265,6 +339,12 @@ end:
        return ret;
 }
 
+int kernctl_tracer_abi_version(int fd,
+               struct lttng_kernel_tracer_abi_version *v)
+{
+       return ioctl(fd, LTTNG_KERNEL_TRACER_ABI_VERSION, v);
+}
+
 int kernctl_wait_quiescent(int fd)
 {
        return compat_ioctl_no_arg(fd, LTTNG_KERNEL_OLD_WAIT_QUIESCENT,
@@ -426,3 +506,9 @@ int kernctl_get_stream_id(int fd, uint64_t *stream_id)
 {
        return ioctl(fd, LTTNG_RING_BUFFER_GET_STREAM_ID, stream_id);
 }
+
+/* Returns the current timestamp. */
+int kernctl_get_current_timestamp(int fd, uint64_t *ts)
+{
+       return ioctl(fd, LTTNG_RING_BUFFER_GET_CURRENT_TIMESTAMP, ts);
+}
This page took 0.02453 seconds and 4 git commands to generate.