From: Julien Desfossez Date: Mon, 11 Dec 2017 19:16:06 +0000 (-0500) Subject: Keep the base directory of a relay session separate X-Git-Tag: v2.11.0-rc1~371 X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=commitdiff_plain;h=2b29c638278807c1536634ce49f0c9c053b3ab5f Keep the base directory of a relay session separate For the session rotation feature, we need a way to modify the path of a channel, so we need to keep the "/" information separate in the consumer_net structure for future use. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- diff --git a/src/bin/lttng-sessiond/consumer.c b/src/bin/lttng-sessiond/consumer.c index dc21e24ca..6351ebe32 100644 --- a/src/bin/lttng-sessiond/consumer.c +++ b/src/bin/lttng-sessiond/consumer.c @@ -715,11 +715,12 @@ int consumer_set_network_uri(struct consumer_output *obj, 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; @@ -1417,8 +1418,11 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, 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; @@ -1427,8 +1431,10 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key, } 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; diff --git a/src/bin/lttng-sessiond/consumer.h b/src/bin/lttng-sessiond/consumer.h index 9186d2f2b..ddc94d714 100644 --- a/src/bin/lttng-sessiond/consumer.h +++ b/src/bin/lttng-sessiond/consumer.h @@ -140,6 +140,9 @@ struct consumer_net { /* Data path for network streaming. */ struct lttng_uri data; + + /* / */ + char base_dir[PATH_MAX]; }; /* diff --git a/src/bin/lttng-sessiond/kernel-consumer.c b/src/bin/lttng-sessiond/kernel-consumer.c index 20a7efb40..10011f4cd 100644 --- a/src/bin/lttng-sessiond/kernel-consumer.c +++ b/src/bin/lttng-sessiond/kernel-consumer.c @@ -69,7 +69,9 @@ static char *create_channel_path(struct consumer_output *consumer, } DBG3("Kernel local consumer tracefile path: %s", pathname); } else { - ret = snprintf(tmp_path, sizeof(tmp_path), "%s", consumer->subdir); + ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s", + consumer->dst.net.base_dir, + consumer->subdir); if (ret < 0) { PERROR("snprintf kernel metadata path"); goto error; diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index a431a19f0..eac995657 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -81,7 +81,10 @@ static char *setup_trace_path(struct consumer_output *consumer, } } } else { - ret = snprintf(pathname, PATH_MAX, "%s%s", consumer->subdir, + ret = snprintf(pathname, PATH_MAX, "%s%s%s%s", + consumer->dst.net.base_dir, + consumer->chunk_path, + consumer->subdir, ua_sess->path); if (ret < 0) { PERROR("snprintf channel path");