break;
case LTTNG_DST_PATH:
DBG2("Setting trace directory path from URI to %s", uri->dst.path);
- memset(consumer->dst.trace_path, 0,
- sizeof(consumer->dst.trace_path));
+ memset(consumer->dst.session_root_path, 0,
+ sizeof(consumer->dst.session_root_path));
/* Explicit length checks for strcpy and strcat. */
if (strlen(uri->dst.path) + strlen(default_trace_dir)
- >= sizeof(consumer->dst.trace_path)) {
+ >= sizeof(consumer->dst.session_root_path)) {
ret = LTTNG_ERR_FATAL;
goto error;
}
- strcpy(consumer->dst.trace_path, uri->dst.path);
+ strcpy(consumer->dst.session_root_path, uri->dst.path);
/* Append default trace dir */
- strcat(consumer->dst.trace_path, default_trace_dir);
+ strcat(consumer->dst.session_root_path, default_trace_dir);
/* Flag consumer as local. */
consumer->type = CONSUMER_DST_LOCAL;
break;
sizeof(sessions[i].path), session);
} else {
ret = snprintf(sessions[i].path, sizeof(sessions[i].path), "%s",
- session->consumer->dst.trace_path);
+ session->consumer->dst.session_root_path);
}
if (ret < 0) {
PERROR("snprintf session path");
}
if (output->consumer->type == CONSUMER_DST_LOCAL) {
if (lttng_strncpy(list[idx].ctrl_url,
- output->consumer->dst.trace_path,
+ output->consumer->dst.session_root_path,
sizeof(list[idx].ctrl_url))) {
ret = -LTTNG_ERR_INVALID;
goto error;
} else {
ret = snprintf(msg.u.snapshot_channel.pathname,
sizeof(msg.u.snapshot_channel.pathname),
- "%s/%s-%s-%" PRIu64 "%s", output->consumer->dst.trace_path,
+ "%s/%s-%s-%" PRIu64 "%s", output->consumer->dst.session_root_path,
output->name, output->datetime, output->nb_snapshot,
session_path);
if (ret < 0) {
uint32_t relay_minor_version;
/*
- * Subdirectory path name used for both local and network consumer.
+ * Subdirectory path name used for both local and network
+ * consumer (/kernel or /ust).
*/
char subdir[PATH_MAX];
unsigned int snapshot:1;
union {
- char trace_path[PATH_MAX];
+ char session_root_path[PATH_MAX];
struct consumer_net net;
} dst;
+
+ /*
+ * Sub-directory below the session_root_path where the next chunk of
+ * trace will be stored (\0 before the first session rotation).
+ */
+ char chunk_path[PATH_MAX];
};
struct consumer_socket *consumer_find_socket(int key,
/* 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);
+ ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s%s",
+ consumer->dst.session_root_path,
+ consumer->chunk_path,
+ consumer->subdir);
if (ret < 0) {
PERROR("snprintf kernel channel path");
goto error;
/* Create directory(ies) on local filesystem. */
if (session->kernel_session->consumer->type == CONSUMER_DST_LOCAL &&
- strlen(session->kernel_session->consumer->dst.trace_path) > 0) {
+ strlen(session->kernel_session->consumer->dst.session_root_path) > 0) {
ret = run_as_mkdir_recursive(
- session->kernel_session->consumer->dst.trace_path,
+ session->kernel_session->consumer->dst.session_root_path,
S_IRWXU | S_IRWXG, session->uid, session->gid);
if (ret < 0) {
if (errno != EEXIST) {
switch (output->type) {
case CONSUMER_DST_LOCAL:
ret = config_writer_write_element_string(writer,
- config_element_path, output->dst.trace_path);
+ config_element_path, output->dst.session_root_path);
if (ret) {
ret = LTTNG_ERR_SAVE_IO_FAIL;
goto end;
}
if (uris[0].dtype == LTTNG_DST_PATH) {
- memset(output->consumer->dst.trace_path, 0,
- sizeof(output->consumer->dst.trace_path));
- if (lttng_strncpy(output->consumer->dst.trace_path,
+ memset(output->consumer->dst.session_root_path, 0,
+ sizeof(output->consumer->dst.session_root_path));
+ if (lttng_strncpy(output->consumer->dst.session_root_path,
uris[0].dst.path,
- sizeof(output->consumer->dst.trace_path))) {
+ sizeof(output->consumer->dst.session_root_path))) {
ret = -LTTNG_ERR_INVALID;
goto error;
}
/* Create directories if consumer is LOCAL and has a path defined. */
if (usess->consumer->type == CONSUMER_DST_LOCAL &&
- strlen(usess->consumer->dst.trace_path) > 0) {
- ret = run_as_mkdir_recursive(usess->consumer->dst.trace_path,
- S_IRWXU | S_IRWXG, ua_sess->euid, ua_sess->egid);
+ usess->consumer->dst.session_root_path[0] != '\0') {
+ char *tmp_path;
+
+ tmp_path = zmalloc(PATH_MAX * sizeof(char));
+ if (!tmp_path) {
+ ERR("Alloc tmp_path");
+ goto error_unlock;
+ }
+ ret = snprintf(tmp_path, PATH_MAX, "%s%s%s",
+ usess->consumer->dst.session_root_path,
+ usess->consumer->chunk_path,
+ usess->consumer->subdir);
+ if (ret >= PATH_MAX) {
+ ERR("Local destination path exceeds the maximal allowed length of %i bytes (needs %i bytes) with path = \"%s%s%s\"",
+ PATH_MAX, ret,
+ usess->consumer->dst.session_root_path,
+ usess->consumer->chunk_path,
+ usess->consumer->subdir);
+ goto error_unlock;
+ }
+
+ DBG("Creating directory path for local tracing: \"%s\"",
+ tmp_path);
+ ret = run_as_mkdir_recursive(tmp_path, S_IRWXU | S_IRWXG,
+ ua_sess->euid, ua_sess->egid);
+ free(tmp_path);
if (ret < 0) {
if (errno != EEXIST) {
ERR("Trace directory creation error");
/* 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);
+ ret = snprintf(pathname, PATH_MAX, "%s%s%s%s",
+ consumer->dst.session_root_path,
+ consumer->chunk_path,
+ consumer->subdir, ua_sess->path);
if (ret < 0) {
PERROR("snprintf channel path");
goto error;