X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=ltt-sessiond%2Fsession.c;h=be820ee552dace6d6c5df188b8d8dee9e2c63681;hp=a4101d2ee8fed3076364b8283504345669c78681;hb=b082db07f0c522527fc95fc97f3e99eb0579c0cc;hpb=8ce37aa529d4d3cc5503605a5a4355395aeb1bd2 diff --git a/ltt-sessiond/session.c b/ltt-sessiond/session.c index a4101d2ee..be820ee55 100644 --- a/ltt-sessiond/session.c +++ b/ltt-sessiond/session.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include "lttngerr.h" @@ -171,9 +172,10 @@ int destroy_session(char *name) int create_session(char *name, char *path) { int ret; + char date_time[NAME_MAX]; struct ltt_session *new_session; - - DBG("Creating session %s at %s", name, path); + time_t rawtime; + struct tm *timeinfo; new_session = find_session_by_name(name); if (new_session != NULL) { @@ -203,7 +205,15 @@ int create_session(char *name, char *path) /* Define session system path */ if (path != NULL) { - if (asprintf(&new_session->path, "%s", path) < 0) { + if (strstr(name, "auto-") == NULL) { + time(&rawtime); + timeinfo = localtime(&rawtime); + strftime(date_time, sizeof(date_time), "-%Y%m%d-%H%M%S", timeinfo); + } else { + date_time[0] = '\0'; + } + + if (asprintf(&new_session->path, "%s/%s%s", path, name, date_time) < 0) { ret = -ENOMEM; goto error_asprintf; } @@ -235,6 +245,8 @@ int create_session(char *name, char *path) /* Add new session to the global session list */ add_session_list(new_session); + DBG("Tracing session %s created in %s", name, new_session->path); + return 0; error: