From a304c14c89f6caecbc08b8cc64d7841700e0401f Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Tue, 20 Dec 2011 21:46:48 -0500 Subject: [PATCH] Create output directory at session creation command Otherwise it is weird to see that we are using a directory that we don't have write access to. Better to fail immediately on the create command. Signed-off-by: Mathieu Desnoyers --- lttng-sessiond/session.c | 13 +++++++++++++ tests/Makefile.am | 1 + 2 files changed, 14 insertions(+) diff --git a/lttng-sessiond/session.c b/lttng-sessiond/session.c index 7a580fdd9..246b60903 100644 --- a/lttng-sessiond/session.c +++ b/lttng-sessiond/session.c @@ -21,10 +21,13 @@ #include #include #include +#include +#include #include #include #include +#include #include "hashtable.h" #include "session.h" @@ -217,6 +220,16 @@ int session_create(char *name, char *path, uid_t uid, gid_t gid) new_session->uid = uid; new_session->gid = gid; + ret = mkdir_recursive_run_as(new_session->path, S_IRWXU | S_IRWXG, + new_session->uid, new_session->gid); + if (ret < 0) { + if (ret != -EEXIST) { + ERR("Trace directory creation error"); + ret = LTTCOMM_CREATE_FAIL; + goto error; + } + } + /* Add new session to the session list */ session_lock_list(); new_session->id = add_session_list(new_session); diff --git a/tests/Makefile.am b/tests/Makefile.am index f64ca5291..382a77225 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,6 +14,7 @@ LIBLTTNG=$(top_srcdir)/liblttngctl/lttngctl.c \ $(top_srcdir)/liblttng-sessiond-comm/lttng-sessiond-comm.c test_sessions_SOURCES = test_sessions.c $(UTILS) $(SESSIONS) +test_sessions_LDADD = $(top_builddir)/librunas/librunas.la test_kernel_data_trace_SOURCES = test_kernel_data_trace.c $(UTILS) $(KERN_DATA_TRACE) -- 2.34.1