+/*
+ * set_session_daemon_path
+ *
+ * Set sessiond socket path by putting it in
+ * the global sessiond_sock_path variable.
+ */
+static int set_session_daemon_path(void)
+{
+ int ret;
+
+ /* 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_enable_event
+ */
+int lttng_kernel_enable_event(struct lttng_event *ev, char *channel_name)
+{
+ int ret;
+
+ if (strlen(channel_name) == 0) {
+ 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);
+ }
+
+ return ret;
+}
+
+/*
+ * lttng_kernel_disable_event
+ *
+ * Disable an event in the kernel tracer.
+ */
+int lttng_kernel_disable_event(char *name, char *channel_name)
+{
+ int ret;
+
+ if (strlen(channel_name) == 0) {
+ strncpy(lsm.u.disable.channel_name, DEFAULT_CHANNEL_NAME, NAME_MAX);
+ } else {
+ strncpy(lsm.u.disable.channel_name, channel_name, NAME_MAX);
+ }
+
+ if (name == NULL) {
+ ret = ask_sessiond(LTTNG_KERNEL_DISABLE_ALL_EVENT, NULL);
+ } else {
+ strncpy(lsm.u.disable.name, name, NAME_MAX);
+ ret = ask_sessiond(LTTNG_KERNEL_DISABLE_EVENT, NULL);
+ }
+
+ return ret;
+}
+
+/*
+ * lttng_kernel_enable_channel
+ *
+ * Enable recording for a channel for the kernel tracer.
+ */
+int lttng_kernel_enable_channel(char *name)
+{
+ strncpy(lsm.u.enable.channel_name, name, NAME_MAX);
+ return ask_sessiond(LTTNG_KERNEL_ENABLE_CHANNEL, NULL);
+}
+
+/*
+ * lttng_kernel_disable_channel
+ *
+ * Disable recording for the channel for the kernel tracer.
+ */
+int lttng_kernel_disable_channel(char *name)
+{
+ return ask_sessiond(LTTNG_KERNEL_DISABLE_CHANNEL, NULL);
+}
+
+/*
+ * lttng_kernel_create_channel
+ *
+ * Create a channel in the kernel tracer.
+ */
+int lttng_kernel_create_channel(struct lttng_channel *chan)
+{
+ memcpy(&lsm.u.channel.chan, chan, sizeof(struct lttng_channel));
+ return ask_sessiond(LTTNG_KERNEL_CREATE_CHANNEL, NULL);
+}
+
+/*
+ * lttng_list_events
+ *
+ * List all available events in the kernel.
+ *
+ * Return the size (bytes) of the list and set the event_list array.
+ * On error, return negative value.
+ */
+int lttng_kernel_list_events(char **event_list)
+{
+ return ask_sessiond(LTTNG_KERNEL_LIST_EVENTS, (void **) event_list);
+}
+
+/*
+ * END Kernel control API
+ */
+