}
output->enabled = obj->enabled;
output->net_seq_index = obj->net_seq_index;
- memcpy(output->subdir, obj->subdir, PATH_MAX);
+ memcpy(output->subdir, obj->subdir, sizeof(output->subdir));
output->snapshot = obj->snapshot;
output->relay_major_version = obj->relay_major_version;
output->relay_minor_version = obj->relay_minor_version;
goto error;
}
- if (lttng_strncpy(obj->subdir, tmp_path, sizeof(obj->subdir))) {
+ if (lttng_strncpy(obj->dst.net.base_dir, tmp_path,
+ sizeof(obj->dst.net.base_dir))) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
- DBG3("Consumer set network uri subdir path %s", tmp_path);
+ DBG3("Consumer set network uri base_dir path %s", tmp_path);
}
return 0;
msg.u.snapshot_channel.use_relayd = 1;
ret = snprintf(msg.u.snapshot_channel.pathname,
sizeof(msg.u.snapshot_channel.pathname),
- "%s/%s-%s-%" PRIu64 "%s", output->consumer->subdir,
- output->name, output->datetime, output->nb_snapshot,
+ "%s/%s/%s-%s-%" PRIu64 "%s",
+ output->consumer->dst.net.base_dir,
+ output->consumer->subdir,
+ output->name, output->datetime,
+ output->nb_snapshot,
session_path);
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
} else {
ret = snprintf(msg.u.snapshot_channel.pathname,
sizeof(msg.u.snapshot_channel.pathname),
- "%s/%s-%s-%" PRIu64 "%s", output->consumer->dst.session_root_path,
- output->name, output->datetime, output->nb_snapshot,
+ "%s/%s-%s-%" PRIu64 "%s",
+ output->consumer->dst.session_root_path,
+ output->name, output->datetime,
+ output->nb_snapshot,
session_path);
if (ret < 0) {
ret = -LTTNG_ERR_NOMEM;
rcu_read_unlock();
return ret;
}
+
+/*
+ * Ask the consumer to create a directory.
+ *
+ * Called with the consumer socket lock held.
+ */
+int consumer_mkdir(struct consumer_socket *socket, uint64_t session_id,
+ const struct consumer_output *output, const char *path,
+ uid_t uid, gid_t gid)
+{
+ int ret;
+ struct lttcomm_consumer_msg msg;
+
+ assert(socket);
+
+ DBG("Consumer mkdir %s in session %" PRIu64, path, session_id);
+
+ memset(&msg, 0, sizeof(msg));
+ msg.cmd_type = LTTNG_CONSUMER_MKDIR;
+ msg.u.mkdir.session_id = session_id;
+ msg.u.mkdir.uid = uid;
+ msg.u.mkdir.gid = gid;
+ ret = snprintf(msg.u.mkdir.path, sizeof(msg.u.mkdir.path), "%s", path);
+ if (ret < 0 || ret >= sizeof(msg.u.mkdir.path)) {
+ ERR("Format path");
+ ret = -1;
+ goto error;
+ }
+
+ if (output->type == CONSUMER_DST_NET) {
+ msg.u.mkdir.relayd_id = output->net_seq_index;
+ } else {
+ msg.u.mkdir.relayd_id = -1ULL;
+ }
+
+ health_code_update();
+ ret = consumer_send_msg(socket, &msg);
+ if (ret < 0) {
+ goto error;
+ }
+
+error:
+ health_code_update();
+ return ret;
+}