X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;ds=sidebyside;f=ltt-sessiond%2Fkernel-ctl.c;h=95463aa50fc96c6d6dfc67b8837fc08daa507dbf;hb=b9f1dd6997ea64db8c140c617d2a74cf90767e3b;hp=bc92ffca918cb07b524aa8b9a6865308e455761b;hpb=d36b858358a8ef4e00de843379d670925f9c23b6;p=lttng-tools.git diff --git a/ltt-sessiond/kernel-ctl.c b/ltt-sessiond/kernel-ctl.c index bc92ffca9..95463aa50 100644 --- a/ltt-sessiond/kernel-ctl.c +++ b/ltt-sessiond/kernel-ctl.c @@ -29,6 +29,68 @@ #include "libkernelctl.h" #include "kernel-ctl.h" +/* + * kernel_add_channel_context + * + * Add context on a kernel channel. + */ +int kernel_add_channel_context(struct ltt_kernel_channel *chan, + struct lttng_kernel_context *ctx) +{ + int ret; + + DBG("Adding context to channel %s", chan->channel->name); + ret = kernctl_add_context(chan->fd, ctx); + if (ret < 0) { + perror("add context ioctl"); + goto error; + } + + chan->ctx = malloc(sizeof(struct lttng_kernel_context)); + if (chan->ctx == NULL) { + perror("malloc event context"); + goto error; + } + + memcpy(chan->ctx, ctx, sizeof(struct lttng_kernel_context)); + + return 0; + +error: + return ret; +} + +/* + * kernel_add_event_context + * + * Add context on a kernel event. + */ +int kernel_add_event_context(struct ltt_kernel_event *event, + struct lttng_kernel_context *ctx) +{ + int ret; + + DBG("Adding context to event %s", event->event->name); + ret = kernctl_add_context(event->fd, ctx); + if (ret < 0) { + perror("add context ioctl"); + goto error; + } + + event->ctx = malloc(sizeof(struct lttng_kernel_context)); + if (event->ctx == NULL) { + perror("malloc event context"); + goto error; + } + + memcpy(event->ctx, ctx, sizeof(struct lttng_kernel_context)); + + return 0; + +error: + return ret; +} + /* * kernel_create_session * @@ -159,6 +221,31 @@ error: return -1; } +/* + * kernel_disable_channel + * + * Disable a kernel channel. + */ +int kernel_disable_channel(struct ltt_kernel_channel *chan) +{ + int ret; + + ret = kernctl_disable(chan->fd); + if (ret < 0) { + perror("disable chan ioctl"); + ret = errno; + goto error; + } + + chan->enabled = 0; + DBG("Kernel channel %s disabled (fd: %d)", chan->channel->name, chan->fd); + + return 0; + +error: + return ret; +} + /* * kernel_enable_channel *