+ /* Are we in the tracing group ? */
+ ret = check_tracing_group(tracing_group);
+ if (ret < 0 && getuid() != 0) {
+ if (sprintf(sessiond_sock_path, DEFAULT_HOME_CLIENT_UNIX_SOCK,
+ getenv("HOME")) < 0) {
+ return -ENOMEM;
+ }
+ } else {
+ strncpy(sessiond_sock_path, DEFAULT_GLOBAL_CLIENT_UNIX_SOCK,
+ sizeof(DEFAULT_GLOBAL_CLIENT_UNIX_SOCK));
+ }
+
+ return 0;
+}
+
+/*
+ * lttng_start_tracing
+ *
+ * Start tracing for all trace of the session.
+ */
+int lttng_start_tracing(char *session_name)
+{
+ strncpy(lsm.session_name, session_name, NAME_MAX);
+ return ask_sessiond(LTTNG_START_TRACE, NULL);
+}
+
+/*
+ * lttng_stop_tracing
+ *
+ * Stop tracing for all trace of the session.
+ */
+int lttng_stop_tracing(char *session_name)
+{
+ strncpy(lsm.session_name, session_name, NAME_MAX);
+ return ask_sessiond(LTTNG_STOP_TRACE, NULL);
+}
+
+/*
+ * BEGIN Kernel control API
+ */
+
+/*
+ * lttng_kernel_add_context
+ */
+int lttng_kernel_add_context(struct lttng_kernel_context *ctx,
+ char *event_name, char *channel_name)
+{
+ if (channel_name != NULL) {
+ strncpy(lsm.u.context.channel_name, channel_name, NAME_MAX);
+ }
+
+ if (event_name != NULL) {
+ strncpy(lsm.u.context.event_name, event_name, NAME_MAX);
+ }
+
+ memcpy(&lsm.u.context.ctx, ctx, sizeof(struct lttng_kernel_context));
+ return ask_sessiond(LTTNG_KERNEL_ADD_CONTEXT, NULL);
+}
+
+/*
+ * lttng_kernel_enable_event
+ */
+int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name)
+{
+ int ret;
+
+ if (channel_name == NULL) {
+ strncpy(lsm.u.enable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
+ } else {
+ strncpy(lsm.u.enable.channel_name, channel_name, NAME_MAX);
+ }
+
+ if (ev == NULL) {
+ ret = ask_sessiond(LTTNG_KERNEL_ENABLE_ALL_EVENT, NULL);
+ } else {
+ memcpy(&lsm.u.enable.event, ev, sizeof(struct lttng_event));
+ ret = ask_sessiond(LTTNG_KERNEL_ENABLE_EVENT, NULL);
+ }