From: Mathieu Desnoyers Date: Wed, 21 Dec 2011 02:46:48 +0000 (-0500) Subject: Create output directory at session creation command X-Git-Tag: v2.0-pre16~7 X-Git-Url: https://git.lttng.org/?a=commitdiff_plain;h=a304c14c89f6caecbc08b8cc64d7841700e0401f;hp=c2b75c490235d87f8a8040f3ddff6b0addceea21;p=lttng-tools.git 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 --- 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)