+static
+long lttng_abi_add_context(struct file *file,
+ struct lttng_kernel_context __user *ucontext_param,
+ struct lttng_ctx **ctx, struct ltt_session *session)
+{
+ struct lttng_kernel_context context_param;
+
+ if (session->been_active)
+ return -EPERM;
+
+ if (copy_from_user(&context_param, ucontext_param, sizeof(context_param)))
+ return -EFAULT;
+
+ switch (context_param.ctx) {
+ case LTTNG_KERNEL_CONTEXT_PID:
+ return lttng_add_pid_to_ctx(ctx);
+ case LTTNG_KERNEL_CONTEXT_PRIO:
+ return lttng_add_prio_to_ctx(ctx);
+ case LTTNG_KERNEL_CONTEXT_NICE:
+ return lttng_add_nice_to_ctx(ctx);
+ case LTTNG_KERNEL_CONTEXT_PERF_COUNTER:
+ return -ENOSYS;
+ case LTTNG_KERNEL_CONTEXT_COMM:
+ return lttng_add_comm_to_ctx(ctx);
+ default:
+ return -EINVAL;
+ }
+}
+