Change trace_path to session_root_path and chunk_path
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 60ff1be03b194eee686aa391e73615039988b3ab..9112cd14e39cf37cafb1d904d3bada5042cfe00b 100644 (file)
@@ -4417,9 +4417,32 @@ int ust_app_start_trace(struct ltt_ust_session *usess, struct ust_app *app)
 
        /* 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");
This page took 0.023432 seconds and 4 git commands to generate.