-static
-int domain_mkdir(const struct consumer_output *output,
- const struct ltt_session *session,
- uid_t uid, gid_t gid)
-{
- struct consumer_socket *socket;
- struct lttng_ht_iter iter;
- int ret;
- char path[LTTNG_PATH_MAX];
-
- if (!output || !output->socks) {
- ERR("No consumer output found");
- ret = -1;
- goto end;
- }
-
- ret = snprintf(path, sizeof(path), "%s/%s%s",
- session_get_base_path(session),
- output->chunk_path,
- output->domain_subdir);
- if (ret < 0 || ret >= LTTNG_PATH_MAX) {
- ERR("Failed to format path new chunk domain path");
- ret = -1;
- goto end;
- }
-
- DBG("Domain mkdir %s for session %" PRIu64, path, session->id);
- rcu_read_lock();
- /*
- * We have to iterate to find a socket, but we only need to send the
- * rename command to one consumer, so we break after the first one.
- */
- cds_lfht_for_each_entry(output->socks->ht, &iter.iter, socket, node.node) {
- pthread_mutex_lock(socket->lock);
- ret = consumer_mkdir(socket, session->id, output, path, uid, gid);
- pthread_mutex_unlock(socket->lock);
- if (ret) {
- ERR("Failed to create directory at \"%s\"", path);
- ret = -1;
- goto end_unlock;
- }
- break;
- }
-
- ret = 0;
-
-end_unlock:
- rcu_read_unlock();
-end:
- return ret;
-}
-