+ /* Get correct path name destination */
+ if (consumer->type == CONSUMER_DST_LOCAL) {
+ /* Set application path to the destination path */
+ ret = snprintf(pathname, PATH_MAX, "%s%s%s",
+ consumer->dst.trace_path, consumer->subdir, ua_sess->path);
+ if (ret < 0) {
+ PERROR("snprintf channel path");
+ goto error;
+ }
+
+ /* Create directory. Ignore if exist. */
+ ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG,
+ ua_sess->euid, ua_sess->egid);
+ if (ret < 0) {
+ if (ret != -EEXIST) {
+ ERR("Trace directory creation error");
+ goto error;
+ }
+ }
+ } else {
+ ret = snprintf(pathname, PATH_MAX, "%s%s", consumer->subdir,
+ ua_sess->path);
+ if (ret < 0) {
+ PERROR("snprintf channel path");
+ goto error;
+ }
+ }
+
+ return pathname;
+
+error:
+ free(pathname);
+ return NULL;
+}
+
+/*
+ * Send a single channel to the consumer using command ADD_CHANNEL.
+ *
+ * Consumer socket lock MUST be acquired before calling this.
+ */
+static int ask_channel_creation(struct ust_app_session *ua_sess,
+ struct ust_app_channel *ua_chan, struct consumer_output *consumer,
+ struct consumer_socket *socket, struct ust_registry_session *registry)
+{
+ int ret;
+ uint32_t chan_id;
+ uint64_t key, chan_reg_key;
+ char *pathname = NULL;
+ struct lttcomm_consumer_msg msg;
+ struct ust_registry_channel *chan_reg;
+
+ assert(ua_sess);
+ assert(ua_chan);
+ assert(socket);
+ assert(consumer);
+ assert(registry);
+
+ DBG2("Asking UST consumer for channel");
+
+ /* Get and create full trace path of session. */
+ if (ua_sess->output_traces) {
+ pathname = setup_trace_path(consumer, ua_sess);
+ if (!pathname) {
+ ret = -1;
+ goto error;
+ }
+ }