From c996624c35518e5c90bcafbbfee5c9bcade1da49 Mon Sep 17 00:00:00 2001 From: Julien Desfossez Date: Mon, 11 Dec 2017 14:41:45 -0500 Subject: [PATCH] Create the session and domain directories on start MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit When the session starts, we now create the folder and the domain folder(s) regardless of the activity or registered apps. This will be useful for the session rotation feature to avoid dealing with empty rotations. Also, it is more consistent for the user to have an empty trace folder instead of no folder at all if a session is completely inactive. This also removes the directory creation made by the session daemon which did not belong there. Signed-off-by: Julien Desfossez Signed-off-by: Jérémie Galarneau --- src/bin/lttng-sessiond/cmd.c | 12 ++++++++++++ src/bin/lttng-sessiond/main.c | 14 -------------- tests/regression/ust/linking/test_linking.py | 3 ++- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 27acbada0..1542fe8e1 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -2519,8 +2519,20 @@ int cmd_start_trace(struct ltt_session *session) goto error; } + if (!session->has_been_started) { + if (!session->snapshot_mode && session->output_traces) { + ret = session_mkdir(session); + if (ret) { + ERR("Failed to create the session directories"); + ret = LTTNG_ERR_CREATE_DIR_FAIL; + goto error; + } + } + } + /* Kernel tracing */ if (ksession != NULL) { + DBG("Start kernel tracing session %s", session->name); ret = start_kernel_session(ksession, kernel_tracer_fd); if (ret != LTTNG_OK) { goto error; diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 114e9c21d..a6c45c2ed 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -2832,20 +2832,6 @@ static int create_kernel_session(struct ltt_session *session) goto error; } - /* Create directory(ies) on local filesystem. */ - if (session->kernel_session->consumer->type == CONSUMER_DST_LOCAL && - strlen(session->kernel_session->consumer->dst.session_root_path) > 0) { - ret = run_as_mkdir_recursive( - session->kernel_session->consumer->dst.session_root_path, - S_IRWXU | S_IRWXG, session->uid, session->gid); - if (ret < 0) { - if (errno != EEXIST) { - ERR("Trace directory creation error"); - goto error; - } - } - } - session->kernel_session->uid = session->uid; session->kernel_session->gid = session->gid; session->kernel_session->output_traces = session->output_traces; diff --git a/tests/regression/ust/linking/test_linking.py b/tests/regression/ust/linking/test_linking.py index 7400091e7..44940f749 100644 --- a/tests/regression/ust/linking/test_linking.py +++ b/tests/regression/ust/linking/test_linking.py @@ -117,7 +117,8 @@ if DYNAMIC_TEST_ENABLED: print_test_result(demo_process.returncode == 0, current_test,\ "Running application dynamically linked to providers, no preload") current_test += 1 - print_test_result(not os.path.exists(session_info.trace_path), current_test,\ + trace_path = os.path.join(session_info.trace_path, "ust", "uid") + print_test_result(not os.path.exists(trace_path), current_test,\ "No events logged when running demo application without preloading providers") current_test += 1 -- 2.34.1