- /* Send streams */
- cds_list_for_each_entry(stream, &channel->stream_list.head, list) {
- if (!stream->fd) {
- continue;
- }
- /* Reset consumer message structure */
- memset(&lkm, 0, sizeof(lkm));
- lkm.cmd_type = LTTNG_CONSUMER_ADD_STREAM;
- lkm.u.stream.channel_key = channel->fd;
- lkm.u.stream.stream_key = stream->fd;
- lkm.u.stream.state = stream->state;
- lkm.u.stream.output = channel->channel->attr.output;
- lkm.u.stream.mmap_len = 0; /* for kernel */
- lkm.u.stream.uid = uid;
- lkm.u.stream.gid = gid;
- strncpy(lkm.u.stream.path_name, stream->pathname, PATH_MAX - 1);
- lkm.u.stream.path_name[PATH_MAX - 1] = '\0';
- count++;
-
- DBG("Sending stream %d to consumer", lkm.u.stream.stream_key);
- ret = lttcomm_send_unix_sock(consumer_sock, &lkm, sizeof(lkm));
+error:
+ return ret;
+}
+
+/*
+ * Sending metadata to the consumer with command ADD_CHANNEL and ADD_STREAM.
+ */
+int kernel_consumer_add_metadata(int sock, struct ltt_kernel_session *session)
+{
+ int ret;
+ char tmp_path[PATH_MAX];
+ const char *pathname;
+ struct lttcomm_consumer_msg lkm;
+ struct consumer_output *consumer;
+
+ /* Safety net */
+ assert(session);
+ assert(session->consumer);
+
+ DBG("Sending metadata %d to kernel consumer", session->metadata_stream_fd);
+
+ /* Get consumer output pointer */
+ consumer = session->consumer;
+
+ /* Get the right path name destination */
+ if (consumer->type == CONSUMER_DST_LOCAL) {
+ /* Set application path to the destination path */
+ ret = snprintf(tmp_path, sizeof(tmp_path), "%s/%s",
+ consumer->dst.trace_path, consumer->subdir);