Fix: snapshot path
authorDavid Goulet <dgoulet@efficios.com>
Fri, 28 Jun 2013 14:54:44 +0000 (10:54 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 28 Jun 2013 14:54:44 +0000 (10:54 -0400)
Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/kernel.c
src/bin/lttng-sessiond/snapshot.c
src/bin/lttng-sessiond/ust-app.c

index 1b7a397335cb0abbe2dbcf07ecf7db578aac85f2..8198629f32638fc181a07cc2c5d28ac6703c062f 100644 (file)
@@ -28,6 +28,7 @@
 #include <common/common.h>
 #include <common/defaults.h>
 #include <common/uri.h>
+#include <common/utils.h>
 
 #include "consumer.h"
 #include "health.h"
@@ -1192,9 +1193,10 @@ end:
  */
 int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
                struct snapshot_output *output, int metadata, uid_t uid, gid_t gid,
-               int wait)
+               const char *session_path, int wait)
 {
        int ret;
+       char datetime[16];
        struct lttcomm_consumer_msg msg;
 
        assert(socket);
@@ -1204,8 +1206,14 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
 
        DBG("Consumer snapshot channel key %" PRIu64, key);
 
-       memset(&msg, 0, sizeof(msg));
+       ret = utils_get_current_time_str("%Y%m%d-%H%M%S", datetime,
+                       sizeof(datetime));
+       if (!ret) {
+               ret = -EINVAL;
+               goto error;
+       }
 
+       memset(&msg, 0, sizeof(msg));
        msg.cmd_type = LTTNG_CONSUMER_SNAPSHOT_CHANNEL;
        msg.u.snapshot_channel.key = key;
        msg.u.snapshot_channel.max_size = output->max_size;
@@ -1215,16 +1223,18 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
                msg.u.snapshot_channel.relayd_id = output->consumer->net_seq_index;
                msg.u.snapshot_channel.use_relayd = 1;
                ret = snprintf(msg.u.snapshot_channel.pathname,
-                               sizeof(msg.u.snapshot_channel.pathname), "%s/%s",
-                               output->consumer->subdir, DEFAULT_SNAPSHOT_NAME);
+                               sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s",
+                               output->consumer->subdir, output->name, datetime,
+                               session_path);
                if (ret < 0) {
                        ret = -LTTNG_ERR_NOMEM;
                        goto error;
                }
        } else {
                ret = snprintf(msg.u.snapshot_channel.pathname,
-                               sizeof(msg.u.snapshot_channel.pathname), "%s/%s",
-                               output->consumer->dst.trace_path, DEFAULT_SNAPSHOT_NAME);
+                               sizeof(msg.u.snapshot_channel.pathname), "%s/%s-%s%s",
+                               output->consumer->dst.trace_path, output->name, datetime,
+                               session_path);
                if (ret < 0) {
                        ret = -LTTNG_ERR_NOMEM;
                        goto error;
index a954a073eed4c5824b37df9048d30fe0aebdfa96..4d8f66a72957cc06f74ef54fde0c6fc45cdc4a16 100644 (file)
@@ -247,6 +247,6 @@ int consumer_flush_channel(struct consumer_socket *socket, uint64_t key);
 /* Snapshot command. */
 int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
                struct snapshot_output *output, int metadata, uid_t uid, gid_t gid,
-               int wait);
+               const char *session_path, int wait);
 
 #endif /* _CONSUMER_H */
index 1ba6b16e6a70e3d1b66c55bfd89aaa5882c3acfb..6f2604c607d2c1bc5fe4c24a53a2cf0458a4053d 100644 (file)
@@ -883,7 +883,7 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
                cds_list_for_each_entry(chan, &ksess->channel_list.head, list) {
                        pthread_mutex_lock(socket->lock);
                        ret = consumer_snapshot_channel(socket, chan->fd, output, 0,
-                                       ksess->uid, ksess->gid, wait);
+                                       ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait);
                        pthread_mutex_unlock(socket->lock);
                        if (ret < 0) {
                                ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
@@ -894,7 +894,7 @@ int kernel_snapshot_record(struct ltt_kernel_session *ksess,
                /* Snapshot metadata, */
                pthread_mutex_lock(socket->lock);
                ret = consumer_snapshot_channel(socket, ksess->metadata->fd, output,
-                               1, ksess->uid, ksess->gid, wait);
+                               1, ksess->uid, ksess->gid, DEFAULT_KERNEL_TRACE_DIR, wait);
                pthread_mutex_unlock(socket->lock);
                if (ret < 0) {
                        ret = LTTNG_ERR_KERN_CONSUMER_FAIL;
index 77255fa2c597f0440e72e8585be486c64e6ef369..ba7cdff2c3a52b3415e464ca8605b71099f7aaaf 100644 (file)
@@ -55,7 +55,7 @@ int snapshot_output_init(uint64_t max_size, const char *name,
        }
        lttng_ht_node_init_ulong(&output->node, (unsigned long) output->id);
 
-       if (name) {
+       if (name && name[0] != '\0') {
                strncpy(output->name, name, sizeof(output->name));
        } else {
                /* Set default name. */
index 56cbb8578544fa56c9f2e6bdf8085483f22064ec..e457cae6803f2ef43491a580ab0f6501171c7494 100644 (file)
@@ -4889,7 +4889,7 @@ int ust_app_snapshot_record(struct ltt_ust_session *usess,
                cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
                                ua_chan, node.node) {
                        ret = consumer_snapshot_channel(socket, ua_chan->key, output, 0,
-                                       ua_sess->euid, ua_sess->egid, wait);
+                                       ua_sess->euid, ua_sess->egid, ua_sess->path, wait);
                        if (ret < 0) {
                                goto error;
                        }
@@ -4898,7 +4898,7 @@ int ust_app_snapshot_record(struct ltt_ust_session *usess,
                registry = get_session_registry(ua_sess);
                assert(registry);
                ret = consumer_snapshot_channel(socket, registry->metadata_key, output,
-                               1, ua_sess->euid, ua_sess->egid, wait);
+                               1, ua_sess->euid, ua_sess->egid, ua_sess->path, wait);
                if (ret < 0) {
                        goto error;
                }
This page took 0.030108 seconds and 4 git commands to generate.